Update fragmentation API.

Update marshal todo.
This commit is contained in:
Captain ALM 2023-05-19 12:35:32 +01:00
parent 8b8cfe142c
commit b49dfa0938
Signed by: alfred
GPG Key ID: 4E4ADD02609997B1
3 changed files with 12 additions and 6 deletions

View File

@ -5,7 +5,7 @@
*/ */
package com.captainalm.lib.calmnet.marshal; package com.captainalm.lib.calmnet.marshal;
/*TODO: /*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) 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 NetMarshalServerWrapped - Constructs NetMarshalClientWrapped instead of NetMarshalClient, stream wrapping support
*/ */

View File

@ -97,10 +97,11 @@ public final class FragmentReceiver {
* Receives a {@link IPacket} into the FragmentReceiver. * Receives a {@link IPacket} into the FragmentReceiver.
* *
* @param packetIn The packet to receive. * @param packetIn The packet to receive.
* @return If the received packet was a fragment packet.
* @throws PacketException A Packet Exception has occurred. * @throws PacketException A Packet Exception has occurred.
*/ */
public void receivePacket(IPacket packetIn) throws PacketException { public boolean receivePacket(IPacket packetIn) throws PacketException {
if (packetIn == null || !packetIn.isValid()) return; if (packetIn == null || !packetIn.isValid()) return false;
if (packetIn instanceof FragmentPIDPacket) { if (packetIn instanceof FragmentPIDPacket) {
synchronized (slock) { synchronized (slock) {
FragmentInput fragmentInput = registry.get(((FragmentPIDPacket) packetIn).getPacketID()); FragmentInput fragmentInput = registry.get(((FragmentPIDPacket) packetIn).getPacketID());
@ -119,7 +120,10 @@ public final class FragmentReceiver {
} }
} }
} }
} else {
return false;
} }
return true;
} }
private int getCurrentID() { private int getCurrentID() {

View File

@ -3,7 +3,6 @@ package com.captainalm.lib.calmnet.packet.fragment;
import com.captainalm.lib.calmnet.packet.IPacket; import com.captainalm.lib.calmnet.packet.IPacket;
import com.captainalm.lib.calmnet.packet.PacketException; import com.captainalm.lib.calmnet.packet.PacketException;
import com.captainalm.lib.calmnet.packet.PacketLoader; import com.captainalm.lib.calmnet.packet.PacketLoader;
import com.captainalm.lib.calmnet.packet.fragment.*;
import java.util.*; import java.util.*;
@ -85,10 +84,11 @@ public final class FragmentSender {
* Receives a {@link IPacket} into the FragmentSender. * Receives a {@link IPacket} into the FragmentSender.
* *
* @param packetIn The packet to receive. * @param packetIn The packet to receive.
* @return If the received packet was a fragment packet.
* @throws PacketException A Packet Exception has occurred. * @throws PacketException A Packet Exception has occurred.
*/ */
public void receivePacket(IPacket packetIn) throws PacketException { public boolean receivePacket(IPacket packetIn) throws PacketException {
if (packetIn == null || !packetIn.isValid()) return; if (packetIn == null || !packetIn.isValid()) return false;
if (packetIn instanceof FragmentPIDPacket) { if (packetIn instanceof FragmentPIDPacket) {
int currentID = ((FragmentPIDPacket) packetIn).getPacketID(); int currentID = ((FragmentPIDPacket) packetIn).getPacketID();
synchronized (slock) { synchronized (slock) {
@ -106,7 +106,9 @@ public final class FragmentSender {
} }
} }
} }
return true;
} }
return false;
} }
/** /**