com.sun.sgs.io
Interface ConnectionListener

All Known Implementing Classes:
SimpleClientConnection

public interface ConnectionListener

Receives asynchronous notification of events from an associated Connection. The connected method is invoked when the connection is established, either actively from a Connector or passively by an Acceptor. The bytesReceived method is invoked when data arrives on the connection. The exceptionThrown method is invoked to forward asynchronous network exceptions. The disconnected method is invoked when the connection has been closed, or if the connection could not be initiated at all (e.g., when a connector fails to connect).

The IO framework ensures that only one notification is processed at a time for each instance of Connection. Thus, a ConnectionListener does not need to take special steps to ensure thread safety so long as it does not access resources shared among the listeners of other connections.


Method Summary
 void bytesReceived(Connection conn, byte[] message)
          Notifies this listener that data arrives on a connection.
 void connected(Connection conn)
          Notifies this listener that the connection is established, either actively from a Connector or passively by an Acceptor.
 void disconnected(Connection conn)
          Notifies this listener that the connection has been closed, or that it could not be initiated (e.g., when a Connector fails to connect).
 void exceptionThrown(Connection conn, Throwable exception)
          Notifies this listener that a network exception has occurred on the connection.
 

Method Detail

connected

void connected(Connection conn)
Notifies this listener that the connection is established, either actively from a Connector or passively by an Acceptor. This indicates that the connection is ready for use, and data may be sent and received on it.

Parameters:
conn - the Connection that has become connected.

bytesReceived

void bytesReceived(Connection conn,
                   byte[] message)
Notifies this listener that data arrives on a connection. The message is not guaranteed to be a single, whole message; this method is responsible for message reassembly unless the connection itself guarantees that only complete messages are delivered.

Parameters:
conn - the Connection on which the message arrived
message - the received message bytes

exceptionThrown

void exceptionThrown(Connection conn,
                     Throwable exception)
Notifies this listener that a network exception has occurred on the connection.

Parameters:
conn - the Connection on which the exception occured
exception - the thrown exception

disconnected

void disconnected(Connection conn)
Notifies this listener that the connection has been closed, or that it could not be initiated (e.g., when a Connector fails to connect).

Parameters:
conn - the Connection that has disconnected

Project Darkstar, Version 0.9.10.8
2013-07-29 21:23:05

Copyright © 2007-2013 Sun Microsystems, Inc. All rights reserved