com.jme3.network.base
クラス MessageProtocol

java.lang.Object
  上位を拡張 com.jme3.network.base.MessageProtocol

public class MessageProtocol
extends java.lang.Object

Consolidates the conversion of messages to/from byte buffers and provides a rolling message buffer. ByteBuffers can be pushed in and messages will be extracted, accumulated, and available for retrieval. This is not thread safe and is meant to be used within a single message processing thread.

The protocol is based on a simple length + data format where two bytes represent the (short) length of the data and the rest is the raw data for the Serializers class.


コンストラクタの概要
MessageProtocol()
           
 
メソッドの概要
 int addBuffer(java.nio.ByteBuffer buffer)
          Adds the specified buffer, extracting the contained messages and making them available to getMessage().
 Message getMessage()
          Retrieves and removes an extracted message from the accumulated buffer or returns null if there are no more messages.
static java.nio.ByteBuffer messageToBuffer(Message message, java.nio.ByteBuffer target)
          Converts a message to a ByteBuffer using the Serializer and the (short length) + data protocol.
 
クラス java.lang.Object から継承されたメソッド
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

コンストラクタの詳細

MessageProtocol

public MessageProtocol()
メソッドの詳細

messageToBuffer

public static java.nio.ByteBuffer messageToBuffer(Message message,
                                                  java.nio.ByteBuffer target)
Converts a message to a ByteBuffer using the Serializer and the (short length) + data protocol. If target is null then a 32k byte buffer will be created and filled.


getMessage

public Message getMessage()
Retrieves and removes an extracted message from the accumulated buffer or returns null if there are no more messages.


addBuffer

public int addBuffer(java.nio.ByteBuffer buffer)
Adds the specified buffer, extracting the contained messages and making them available to getMessage(). The left over data is buffered to be combined with future data. &

戻り値:
The total number of queued messages after this call.