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 Type
    Method
    Description
    boolean
    Adds byte data to the message buffer.
    boolean
    Returns 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

      boolean addBytes(ByteBuffer buffer)
      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