public final class FragmentSender
extends java.lang.Object
com.captainalm.lib.calmnet.packet.fragment
.Constructor and Description |
---|
FragmentSender(PacketLoader loader)
Constructs a new FragmentSender with the specified
PacketLoader . |
FragmentSender(PacketLoader loader,
int newSize)
Constructs a new FragmentSender with the specified
PacketLoader
and packet split size in bytes. |
Modifier and Type | Method and Description |
---|---|
boolean |
areFinishedIDsWaiting()
Gets whether finished IDs are waiting for obtaining.
|
boolean |
arePacketsWaiting()
Gets whether packets are waiting for allocation.
|
void |
clearLastIDFinished()
Clears all the last finished packet IDs.
|
void |
clearRegistry()
Clears the registry.
|
void |
clearWaitingPackets()
Clears the currently waiting packets.
|
void |
deletePacketFromRegistry(int id)
Deletes a packet from the registry.
|
int |
getLastIDFinished()
Gets the last finished packet ID.
|
PacketLoader |
getPacketLoader()
Gets the
PacketLoader in use. |
int |
getSplitSize()
Gets the current packet split size in bytes.
|
java.lang.Integer |
pollLastIDFinished()
Polls the last finished packet ID.
|
boolean |
receivePacket(IPacket packetIn)
Receives a
IPacket into the FragmentSender. |
IPacket[] |
sendPacket()
Sends the current
IPacket s from the FragmentSender. |
void |
sendPacket(IPacket packetIn)
Sends a
IPacket using this FragmentSender. |
void |
setPacketLoader(PacketLoader loader)
Sets the
PacketLoader to use. |
void |
setResponseVerification(boolean state)
Sets whether responses should be verified by checking if they are equal.
|
void |
setSentDataWillBeAllVerified(boolean state)
Gets whether all sent fragments are verified via resend checks for equality.
|
void |
setSplitSize(int newSize)
Sets the packet split size in bytes.
|
boolean |
shouldSentDataBeAllVerified()
Gets whether all sent fragments are verified via resend checks for equality.
|
boolean |
shouldVerifyResponses()
Gets whether responses should be verified by checking if they are equal.
|
void |
stopAllDataVerificationAndCompleteSend()
Stops data verification for all packets being sent when
shouldSentDataBeAllVerified() is true. |
void |
stopDataVerificationAndCompleteSend(int id)
Stops data verification for the specified Packet ID when
shouldSentDataBeAllVerified() is true. |
public FragmentSender(PacketLoader loader)
PacketLoader
.loader
- The packet loader to use.java.lang.NullPointerException
- loader is null.public FragmentSender(PacketLoader loader, int newSize)
PacketLoader
and packet split size in bytes.loader
- The packet loader to use.newSize
- The new split size.java.lang.NullPointerException
- loader is null.java.lang.IllegalArgumentException
- newSize is less than 1.public void sendPacket(IPacket packetIn)
IPacket
using this FragmentSender.packetIn
- The packet to fragment and send.public IPacket[] sendPacket() throws PacketException
IPacket
s from the FragmentSender.PacketException
- A Packet Exception has occurred.public boolean receivePacket(IPacket packetIn) throws PacketException
IPacket
into the FragmentSender.packetIn
- The packet to receive.PacketException
- A Packet Exception has occurred.public boolean arePacketsWaiting()
public void clearWaitingPackets()
public void deletePacketFromRegistry(int id)
id
- The ID of the packet to remove.public void clearRegistry()
public boolean areFinishedIDsWaiting()
public int getLastIDFinished() throws java.lang.InterruptedException
java.lang.InterruptedException
- The Thread was Interrupted.public java.lang.Integer pollLastIDFinished()
public void clearLastIDFinished()
public int getSplitSize()
public void setSplitSize(int newSize)
newSize
- The new packet split size.java.lang.IllegalArgumentException
- newSize is less than 1.public PacketLoader getPacketLoader()
PacketLoader
in use.public void setPacketLoader(PacketLoader loader)
PacketLoader
to use.loader
- The packet loader to use.java.lang.NullPointerException
- loader is null.public boolean shouldVerifyResponses()
public void setResponseVerification(boolean state)
setSentDataWillBeAllVerified(boolean)
will be set to false too.state
- If responses should be verified.public boolean shouldSentDataBeAllVerified()
public void setSentDataWillBeAllVerified(boolean state)
setResponseVerification(boolean)
set to true.state
- If all sent fragments will be verified via resend checks for equality.public void stopDataVerificationAndCompleteSend(int id)
shouldSentDataBeAllVerified()
is true.id
- The PacketID to act on.public void stopAllDataVerificationAndCompleteSend()
shouldSentDataBeAllVerified()
is true.