From b49dfa09388d12b5d5d530f3ec3acd68639ff45c Mon Sep 17 00:00:00 2001 From: Captain ALM Date: Fri, 19 May 2023 12:35:32 +0100 Subject: [PATCH] Update fragmentation API. Update marshal todo. --- src/com/captainalm/lib/calmnet/marshal/package-info.java | 2 +- .../lib/calmnet/packet/fragment/FragmentReceiver.java | 8 ++++++-- .../lib/calmnet/packet/fragment/FragmentSender.java | 8 +++++--- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/com/captainalm/lib/calmnet/marshal/package-info.java b/src/com/captainalm/lib/calmnet/marshal/package-info.java index e182b66..f74f0fe 100644 --- a/src/com/captainalm/lib/calmnet/marshal/package-info.java +++ b/src/com/captainalm/lib/calmnet/marshal/package-info.java @@ -5,7 +5,7 @@ */ package com.captainalm.lib.calmnet.marshal; /*TODO: -NetMarshalClientWrapped - Stream wrapping support +NetMarshalClient(Wrapped) - Fragmentation processing support NetMarshalServer - Has a thread for UDP receiving and has a dictionary of input streams (final, created in constructor) NetMarshalServerWrapped - Constructs NetMarshalClientWrapped instead of NetMarshalClient, stream wrapping support */ \ No newline at end of file diff --git a/src/com/captainalm/lib/calmnet/packet/fragment/FragmentReceiver.java b/src/com/captainalm/lib/calmnet/packet/fragment/FragmentReceiver.java index fb2f1e3..aba8893 100644 --- a/src/com/captainalm/lib/calmnet/packet/fragment/FragmentReceiver.java +++ b/src/com/captainalm/lib/calmnet/packet/fragment/FragmentReceiver.java @@ -97,10 +97,11 @@ public final class FragmentReceiver { * Receives a {@link IPacket} into the FragmentReceiver. * * @param packetIn The packet to receive. + * @return If the received packet was a fragment packet. * @throws PacketException A Packet Exception has occurred. */ - public void receivePacket(IPacket packetIn) throws PacketException { - if (packetIn == null || !packetIn.isValid()) return; + public boolean receivePacket(IPacket packetIn) throws PacketException { + if (packetIn == null || !packetIn.isValid()) return false; if (packetIn instanceof FragmentPIDPacket) { synchronized (slock) { FragmentInput fragmentInput = registry.get(((FragmentPIDPacket) packetIn).getPacketID()); @@ -119,7 +120,10 @@ public final class FragmentReceiver { } } } + } else { + return false; } + return true; } private int getCurrentID() { diff --git a/src/com/captainalm/lib/calmnet/packet/fragment/FragmentSender.java b/src/com/captainalm/lib/calmnet/packet/fragment/FragmentSender.java index f7c405e..7aff8a8 100644 --- a/src/com/captainalm/lib/calmnet/packet/fragment/FragmentSender.java +++ b/src/com/captainalm/lib/calmnet/packet/fragment/FragmentSender.java @@ -3,7 +3,6 @@ package com.captainalm.lib.calmnet.packet.fragment; import com.captainalm.lib.calmnet.packet.IPacket; import com.captainalm.lib.calmnet.packet.PacketException; import com.captainalm.lib.calmnet.packet.PacketLoader; -import com.captainalm.lib.calmnet.packet.fragment.*; import java.util.*; @@ -85,10 +84,11 @@ public final class FragmentSender { * Receives a {@link IPacket} into the FragmentSender. * * @param packetIn The packet to receive. + * @return If the received packet was a fragment packet. * @throws PacketException A Packet Exception has occurred. */ - public void receivePacket(IPacket packetIn) throws PacketException { - if (packetIn == null || !packetIn.isValid()) return; + public boolean receivePacket(IPacket packetIn) throws PacketException { + if (packetIn == null || !packetIn.isValid()) return false; if (packetIn instanceof FragmentPIDPacket) { int currentID = ((FragmentPIDPacket) packetIn).getPacketID(); synchronized (slock) { @@ -106,7 +106,9 @@ public final class FragmentSender { } } } + return true; } + return false; } /**