TopoWeb Commons API

org.topoweb.net.server
Interface Session

All Known Implementing Classes:
PlainSession

public interface Session

Encapsulates a socket's conversational state.

Session instances are not long-lived. That is, an instance is not supposed to span over the lifetime of multiple socket connections.

Session instances are passed around as event objects in queues. These event objects (Sessions) are then processed (consumed) in stages.

Author:
Babak Farhang
See Also:
SessionPool

Method Summary
 void appendReadBuffer(java.nio.ByteBuffer buffer)
          Append the given buffer into this instance's internal "read buffer".
 int getReadAmount()
          Returns the content-length of the internal "read buffer".
 byte[] getReadArray()
          Returns the internal "read buffer".
 java.nio.channels.SocketChannel getSocketChannel()
          Returns the socket channel used by this session.
 java.nio.ByteBuffer[] getWriteBuffers()
          Returns the "write buffers".
 void setWriteBuffers(java.nio.ByteBuffer[] buffers)
          Sets the "write buffers".
 

Method Detail

getSocketChannel

public java.nio.channels.SocketChannel getSocketChannel()
Returns the socket channel used by this session.


appendReadBuffer

public void appendReadBuffer(java.nio.ByteBuffer buffer)
Append the given buffer into this instance's internal "read buffer". The "read amount" is incremented by the buffer.remaining().

Parameters:
buffer - the buffer whose contents are appended
See Also:
getReadArray(), getReadAmount()

getReadArray

public byte[] getReadArray()
Returns the internal "read buffer". The bytes actually read begin at the zero offset and is of the length specified by the getReadAmount() method.

Returns:
the intenal read buffer
See Also:
appendReadBuffer(ByteBuffer), getReadAmount()

getReadAmount

public int getReadAmount()
Returns the content-length of the internal "read buffer".

Returns:
the number of bytes appended into the read buffer
See Also:
appendReadBuffer(ByteBuffer), getReadArray()

setWriteBuffers

public void setWriteBuffers(java.nio.ByteBuffer[] buffers)
Sets the "write buffers". The given buffers are to be written out to the client.

Parameters:
buffers - the write buffers
See Also:
getWriteBuffers()

getWriteBuffers

public java.nio.ByteBuffer[] getWriteBuffers()
Returns the "write buffers". The returned buffers are to be written out to the client.

Returns:
the write buffers
See Also:
setWriteBuffers(ByteBuffer[])

TopoWeb Commons API

Copyright (C) 2002 Babak Farhang

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.