|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.officefloor.plugin.socket.server.tcp.protocol.TcpConnectionHandler
public class TcpConnectionHandler
TCP ConnectionHandler.
| Constructor Summary | |
|---|---|
TcpConnectionHandler(TcpCommunicationProtocol protocol,
Connection connection,
int sendBufferSize,
long maxIdleTime)
Initiate. |
|
| Method Summary | |
|---|---|
void |
close()
Flags to close the WriteBufferReceiver. |
WriteBuffer |
createWriteBuffer(byte[] data,
int length)
Creates a WriteBuffer for the data. |
WriteBuffer |
createWriteBuffer(ByteBuffer buffer)
Creates the WriteBuffer for the ByteBuffer. |
ServerInputStream |
getInputStream()
Obtains the ServerInputStream that provides access to the data sent
from the client. |
Object |
getLock()
Obtains the lock to synchronize for using this
WriteBufferReceiver. |
Object |
getObject()
Obtains the object being managed. |
ServerOutputStream |
getOutputStream()
Obtains the ServerOutputStream to write data back to the client. |
void |
handleHeartbeat(HeartBeatContext context)
Handles a heart beat on Connection. |
void |
handleRead(ReadContext context)
Handles a read from the SocketChannel. |
boolean |
isClosed()
Indicates if the WriteBufferReceiver is closed. |
void |
registerAsynchronousCompletionListener(AsynchronousListener listener)
Provides the AsynchronousListener to the
AsynchronousManagedObject to enable call back to notify state and
completion of asynchronous processing. |
boolean |
waitOnClientData()
Flags for the ManagedObject to not execute another Task
until further data is received from the client. |
void |
writeData(WriteBuffer[] data)
Writes data to client of this Connection. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public TcpConnectionHandler(TcpCommunicationProtocol protocol,
Connection connection,
int sendBufferSize,
long maxIdleTime)
protocol - TcpCommunicationProtocol.connection - Connection.sendBufferSize - Send buffer size.maxIdleTime - Maximum idle time for the Connection measured in
milliseconds.| Method Detail |
|---|
public void handleHeartbeat(HeartBeatContext context)
throws IOException
ConnectionHandler
Handles a heart beat on Connection.
Typical use of the heart beat is to allow the ConnectionHandler
to close an idle Connection.
handleHeartbeat in interface ConnectionHandlercontext - HeartBeatContext.
IOException - If fails to handle heart beat. Possibly from attempting to
close it.
public void handleRead(ReadContext context)
throws IOException
ConnectionHandlerSocketChannel.
handleRead in interface ConnectionHandlercontext - ReadContext.
IOException - If fails to obtain data from the ReadContext.public Object getLock()
WriteBufferReceiversynchronize for using this
WriteBufferReceiver.
getLock in interface WriteBufferReceiverWriteBufferReceiver.
public WriteBuffer createWriteBuffer(byte[] data,
int length)
WriteBufferReceiverWriteBuffer for the data.
createWriteBuffer in interface WriteBufferReceiverdata - Data.length - Length of data.
WriteBuffer.public WriteBuffer createWriteBuffer(ByteBuffer buffer)
WriteBufferReceiverWriteBuffer for the ByteBuffer.
createWriteBuffer in interface WriteBufferReceiverbuffer - ByteBuffer.
WriteBuffer.
public void writeData(WriteBuffer[] data)
throws IOException
WriteBufferReceiverConnection.
writeData in interface WriteBufferReceiverdata - Data to be written.
IOException - If fails to write data.
public void close()
throws IOException
WriteBufferReceiver
Flags to close the WriteBufferReceiver.
Close occurs after all data has been written.
close in interface WriteBufferReceiverIOException - If fails to close.public boolean isClosed()
WriteBufferReceiverWriteBufferReceiver is closed.
isClosed in interface WriteBufferReceivertrue if the WriteBufferReceiver is closed.public void registerAsynchronousCompletionListener(AsynchronousListener listener)
AsynchronousManagedObjectAsynchronousListener to the
AsynchronousManagedObject to enable call back to notify state and
completion of asynchronous processing.
registerAsynchronousCompletionListener in interface AsynchronousManagedObjectlistener - AsynchronousListener.public Object getObject()
ManagedObject
getObject in interface ManagedObject
public boolean waitOnClientData()
throws IOException
ServerTcpConnection
Flags for the ManagedObject to not execute another Task
until further data is received from the client.
On calling this the next time a Task is invoked using this
ManagedObject, data will be available from the
ServerInputStream.
waitOnClientData in interface ServerTcpConnectiontrue indicating if will wait on client data.
false if client data is available and therefore will
not wait.
IOException - If fails to initiate waiting on client.public ServerInputStream getInputStream()
ServerTcpConnectionServerInputStream that provides access to the data sent
from the client.
getInputStream in interface ServerTcpConnectionServerInputStream.public ServerOutputStream getOutputStream()
ServerTcpConnection
Obtains the ServerOutputStream to write data back to the client.
Closing the ServerOutputStream will result in closing the
Connection.
getOutputStream in interface ServerTcpConnectionServerOutputStream.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||