public interface PacketFormat
Modifier and Type | Method and Description |
---|---|
boolean |
canSend(SessionKey key)
Returns
false if the packet format can't send new messages because it must wait for some internal event. |
void |
checkForLostPackets() |
boolean |
fullPacketQueued(int maxPacketSize)
Is there enough data queued to justify sending a packet immediately? Ideally
this should take into account transport level headers.
|
boolean |
handleReceivedPacket(byte[] buf,
int offset,
int length,
long now,
Peer replyTo) |
boolean |
maybeSendPacket(long now,
boolean ackOnly)
Maybe send something.
|
java.util.List<MessageItem> |
onDisconnect()
Called when the peer has been disconnected.
|
long |
timeCheckForLostPackets() |
long |
timeNextUrgent(boolean canSend,
long now) |
long |
timeSendAcks() |
boolean handleReceivedPacket(byte[] buf, int offset, int length, long now, Peer replyTo)
boolean maybeSendPacket(long now, boolean ackOnly) throws BlockedTooLongException
ackOnly
- BlockedTooLongException
java.util.List<MessageItem> onDisconnect()
boolean canSend(SessionKey key)
false
if the packet format can't send new messages because it must wait for some internal event.
For example, if a packet sequence number can not be allocated this method should return false
, but if
nothing can be sent because there is no (external) data to send it should not.
Note that this only applies to packets being created from messages on the @see PeerMessageQueue.
Note also that there may already be messages in flight, but it may return false in that
case, so you need to check timeNextUrgent() as well.false
if the packet format can't send packetslong timeNextUrgent(boolean canSend, long now)
canSend
- If false, canSend() has returned false. Some transports will
want to send a packet anyway e.g. an ack, a resend in some cases.long timeSendAcks()
boolean fullPacketQueued(int maxPacketSize)
void checkForLostPackets()
long timeCheckForLostPackets()