asynctcp
Interface ConnectionListener


public interface ConnectionListener

An common interface for listeners on both incoming and outgoing connections.

Author:
Michael Parker

Method Summary
 boolean bytesReceived(java.nio.ByteBuffer bb, Connection conn, ProcessReadyCallback prc)
          This callback method is invoked when data is received from the remote node.
 void changeStatus(Connection.ConnectionState prev_state, Connection.ConnectionState curr_state, Connection conn)
          This callback method is invoked when the state of the connection changes.
 

Method Detail

changeStatus

void changeStatus(Connection.ConnectionState prev_state,
                  Connection.ConnectionState curr_state,
                  Connection conn)
This callback method is invoked when the state of the connection changes.

Parameters:
prev_state - the previous connection state
curr_state - the current connection state
conn - the connection that changed state

bytesReceived

boolean bytesReceived(java.nio.ByteBuffer bb,
                      Connection conn,
                      ProcessReadyCallback prc)
This callback method is invoked when data is received from the remote node. If the implementor of this callback is ready to empty the buffer immediately, then it should do so and return true. Note that after the client empties the buffer, its compact method should not be invoked. Additionally, if this method returns true but removes nothing from the buffer, then its contents are simply discarded. Otherwise, if the implementor is not ready to empty the buffer immediately, it should return false and keep a reference to the provided ProcessReadyCallback argument. When method nowReady is invoked on this object, then the ASyncTCP instance will invoke this method again.

Parameters:
bb - a ByteBuffer containing the received data
conn - the connection from which data was received
prc - the object through which the client later notifies the ASyncTCP instance that it is ready to drain bb if this method returns false
Returns:
true if the client was ready to empty the buffer, false otherwise