Class LazyMessageBuffer

java.lang.Object
com.jme3.network.base.protocol.LazyMessageBuffer
All Implemented Interfaces:
MessageBuffer

public class LazyMessageBuffer extends Object implements MessageBuffer
A MessageBuffer implementation that will deserialize messages as they are returned instead of deserializing them as the data comes in. This allows the individual messages to be processed before later messages are deserialized, thus allowing the serialization process itself to be altered mid-stream.
Author:
Paul Speed
  • Constructor Details

    • LazyMessageBuffer

      public LazyMessageBuffer(MessageProtocol protocol)
      Creates a lazy message buffer for the specified protocol.
      Parameters:
      protocol - the protocol used to deserialize buffered messages
  • Method Details

    • pollMessage

      public Message pollMessage()
      Returns the next message in the buffer or null if there are no more messages in the buffer.
      Specified by:
      pollMessage in interface MessageBuffer
      Returns:
      the next buffered message, or null if none are ready
    • hasMessages

      public boolean hasMessages()
      Returns true if there is a message waiting in the buffer.
      Specified by:
      hasMessages in interface MessageBuffer
      Returns:
      true if a message can be polled immediately
    • addBytes

      public boolean addBytes(ByteBuffer buffer)
      Adds byte data to the message buffer. Returns true if there is a message waiting after this call.
      Specified by:
      addBytes in interface MessageBuffer
      Parameters:
      buffer - the bytes to add
      Returns:
      true if a complete message is now available