
public class ConnectionDataHandler extends Object implements org.xsocket.connection.IWriteCompletionHandler, ISocketServerConnection, ISocketServerProtocolDecoderListener
| Constructor and Description |
|---|
ConnectionDataHandler(org.xsocket.connection.INonBlockingConnection connection,
ISocketServerConnectionListener listener,
ISocketSeverProtocolDecoder protocolDecoder)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the connection.
|
void |
decode(byte[] newData)
Decodes incoming data.
|
void |
errorDecoding(String errorDecoding)
Error produced while decoding data.
|
org.xsocket.connection.INonBlockingConnection |
getConnection()
getConnectionSynchronized.
|
int |
getConnectionReceivedPackets()
Gets the total number of received packets.
|
int |
getConnectionSentPackets()
Gets the total number of sent packets.
|
int |
getId()
Returns the connection identifier.
|
ISocketServerConnectionListener |
getListener()
Returns the listener.
|
InetAddress |
getRemoteAddress()
Returns the remote IP address.
|
int |
getRemotePort()
Returns the remote port.
|
boolean |
isConnectionClosed()
Returns true if the connections is closed.
|
void |
onException(IOException ioe)
Exception raised while trying to write.
|
void |
onWritten(int written)
Callback method that notifies that a packet has been sent.
|
void |
packetReceived(Object pckt)
Method called by the protocol decoder when a new packet has been
assembled.
|
void |
setConnectionLister(ISocketServerConnectionListener listener)
Set the listener.
|
void |
setId(int connectionId)
.
|
void |
writeToConnection(ByteBuffer data)
Writes data to connection.
|
public ConnectionDataHandler(org.xsocket.connection.INonBlockingConnection connection,
ISocketServerConnectionListener listener,
ISocketSeverProtocolDecoder protocolDecoder)
connection - xSocket connection that wraps the socket channellistener - connection listenerprotocolDecoder - connection protocol decoderpublic void close()
close in interface Closeableclose in interface AutoCloseablepublic void decode(byte[] newData)
newData - incoming new datapublic int getConnectionReceivedPackets()
getConnectionReceivedPackets in interface ISocketServerConnectionpublic int getConnectionSentPackets()
getConnectionSentPackets in interface ISocketServerConnectionpublic int getId()
getId in interface ISocketServerConnectionpublic boolean isConnectionClosed()
isConnectionClosed in interface ISocketServerConnectionpublic void onException(IOException ioe)
onException in interface org.xsocket.connection.IWriteCompletionHandlerioe - error while trying to write to the connection.public void onWritten(int written)
throws IOException
onWritten in interface org.xsocket.connection.IWriteCompletionHandlerwritten - the size of the packet writtenIOException - error handling onWritten eventIWriteCompletionHandler.onWritten(int)public void packetReceived(Object pckt)
packetReceived in interface ISocketServerProtocolDecoderListenerpckt - the new assembled packetpublic void setId(int connectionId)
setId in interface ISocketServerConnectionconnectionId - integer used to identify the connection.public void writeToConnection(ByteBuffer data)
onWritten is called after the packet has
been written.writeToConnection in interface ISocketServerConnectiondata - data to be writtenpublic InetAddress getRemoteAddress()
getRemoteAddress in interface ISocketServerConnectionpublic org.xsocket.connection.INonBlockingConnection getConnection()
public void errorDecoding(String errorDecoding)
errorDecoding in interface ISocketServerProtocolDecoderListenererrorDecoding - .public ISocketServerConnectionListener getListener()
public void setConnectionLister(ISocketServerConnectionListener listener)
setConnectionLister in interface ISocketServerConnectionlistener - listener.public int getRemotePort()
ISocketServerConnectiongetRemotePort in interface ISocketServerConnectionCopyright © 2018 universAAL Consortium. All rights reserved.