rice.pastry.wire
Class SocketChannelReader
- public class SocketChannelReader
- Class which serves as an "reader" for messages sent across the wire via the Pastry socket protocol. This class builds up an object as it is being sent across the wire, and when it has recieved all of an object, it informs the WirePastryNode by using the recieveMessage(msg) method. The SocketChannelReader is designed to be reused, to read objects continiously off of one stream.
- Version:
- $Id: SocketChannelReader.java,v 1.4 2002/09/03 03:52:10 amislove Exp $
- Author:
- Alan Mislove
SocketChannelReader
public SocketChannelReader(rice.pastry.wire.WirePastryNode spn)
- Constructor which creates this SocketChannelReader and the WirePastryNode. Once the reader has completely read a message, it deserializes the message and hands it off to the pastry node.
- Parameters:
spn
- The PastryNode the SocketChannelReader serves.
read
public java.lang.Object read(java.nio.channels.SocketChannel sc)
- Method which is to be called when there is data available on the specified SocketChannel. The data is read in, and if the object is done being read, it is parsed.
- Parameters:
sc
- The channel to read from.
- Returns:
- The object read off the stream, or null if no object has been completely read yet
initializeObjectBuffer
private void initializeObjectBuffer()
- Private method which is designed to read the header of the incoming message, and prepare the buffer for the object appropriately.
deserialize
private java.lang.Object deserialize(byte[] array)
- Method which parses an object once it is ready, and notifies the pastry node of the message.
- Returns:
- the deserialized object
reset
public void reset()
- Resets this input stream so that it is ready to read another object off of the queue.