org.xsocket.stream.io.spi
Interface IIoHandlerCallback

Package class diagram package IIoHandlerCallback

public interface IIoHandlerCallback

Call back interface to notify io events of the IIoHandler. The IIoHandler is responsible to notify the events in the occured order.

This class is experimental and is subject to change


Method Summary
 void onConnect()
          notifies that the underlying connection has been established.
 void onConnectionAbnormalTerminated()
          notifies that the connection has to be closed (connection is corrupt, selector has be closed, ...).
 void onConnectionTimeout()
          notifies the connection time out has been occured.
 void onDataRead()
          notifies that data has been read from the socket.
 void onDisconnect()
          notifies that the underlying connection has been disconnected (closed).
 void onIdleTimeout()
          notifies the idle time out has been occured.
 void onWriteException(java.io.IOException ioException)
          notifies that an error has been occured by writing data on the socket.
 void onWritten()
          notifies that data has been written on the socket.
 

Method Detail

onDataRead

void onDataRead()
notifies that data has been read from the socket.

This method has to be called by a worker thread if the IIoHandlerContext.getWorkerpool() is not null. If the IIoHandlerContext.getWorkerpool() is null, no dedicate worker threads will be used (non-multithreading mode).
The callback method will only be called if the IIoHandlerContext.isAppHandlerListenForDataEvent() method returns true. If the handler requires synchronization (IIoHandlerContext#getAppHandlerSynchronizationMode() != Synchronized.Mode#OFF), the callback method has to be called in a synchronized context.


onConnect

void onConnect()
notifies that the underlying connection has been established.
The callback method will only be called if the IIoHandlerContext.isAppHandlerListenForConnectEvent() method returns true. If the handler is not thread-safe (IIoHandlerContext.isAppHandlerThreadSafe() is false), the callback method has to be called in a synchronized context.

The threading behaivour is equals to onDataRead()


onDisconnect

void onDisconnect()
notifies that the underlying connection has been disconnected (closed).
The callback method will only be called if the IIoHandlerContext.isAppHandlerListenforDisconnectEvent() method returns true. If the handler is not thread-safe (IIoHandlerContext.isAppHandlerThreadSafe() is false), the callback method has to be called in a synchronized context.

The threading behaivour is equals to onDataRead()


onIdleTimeout

void onIdleTimeout()
notifies the idle time out has been occured.
The callback method will only be called if the IIoHandlerContext.isAppHandlerListenForTimeoutEvent() method returns true. If the handler is not thread-safe (IIoHandlerContext.isAppHandlerThreadSafe() is false), the callback method has to be called in a synchronized context.

The threading behaivour is equals to onDataRead()


onConnectionTimeout

void onConnectionTimeout()
notifies the connection time out has been occured.
The callback method will only be called if the IIoHandlerContext.isAppHandlerListenForTimeoutEvent() method returns true. If the handler is not thread-safe (IIoHandlerContext.isAppHandlerThreadSafe() is false), the callback method has to be called in a synchronized context.

The threading behaivour is equals to onDataRead()


onConnectionAbnormalTerminated

void onConnectionAbnormalTerminated()
notifies that the connection has to be closed (connection is corrupt, selector has be closed, ...). This call back method will NOT be called in the case of idle or connection time out.

The threading behaivour is equals to onDataRead()


onWritten

void onWritten()
notifies that data has been written on the socket.

For performance reasons this method shouldn`t be performed by a worker thread.


onWriteException

void onWriteException(java.io.IOException ioException)
notifies that an error has been occured by writing data on the socket.

For performance reasons this method shouldn`t be performed by a worker thread.

Parameters:
ioe - ioException an io exception