Interface MessageBuffer
- All Known Implementing Classes:
GreedyMessageBuffer, LazyMessageBuffer
public interface MessageBuffer
Accumulates network data into Message objects. This allows
random chunks of bytes to be assembled into messages even if
the buffer boundaries don't line up.
- Author:
- Paul Speed
-
Method Summary
Modifier and TypeMethodDescriptionbooleanaddBytes(ByteBuffer buffer) Adds byte data to the message buffer.booleanReturns true if there is a message waiting in the buffer.Returns the next message in the buffer or null if there are no more messages in the buffer.
-
Method Details
-
pollMessage
Message pollMessage()Returns the next message in the buffer or null if there are no more messages in the buffer.- Returns:
- the next buffered message, or null if none are ready
-
hasMessages
boolean hasMessages()Returns true if there is a message waiting in the buffer.- Returns:
- true if a message can be polled immediately
-
addBytes
Adds byte data to the message buffer. Returns true if there is a message waiting after this call.- Parameters:
buffer- the bytes to add- Returns:
- true if a complete message is now available
-