|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.sgs.impl.client.simple.SimpleClientConnection
class SimpleClientConnection
A ClientConnection is the central point of communication with the
server. This SimpleClientConnection uses an Connection
for its transport. All outbound messages to the server go out via the
Connection.send. Incoming messages come in on the
ConnectionListener.messageReceived callback and are dispatched to
the appropriate callback on either the associated
ClientConnectionListener.
| Constructor Summary | |
|---|---|
SimpleClientConnection(ClientConnectionListener listener)
Creates a new connection implementation. |
|
| 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 |
disconnect()
Asynchronously closes the connection, freeing any resources in use. |
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. |
void |
sendMessage(ByteBuffer message)
Asynchronously sends data to the server. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
SimpleClientConnection(ClientConnectionListener listener)
listener - the listener to receive notification of events| Method Detail |
|---|
public void disconnect()
throws IOException
ClientConnectionListener.disconnected(boolean, byte[]) is invoked.
This implementation disconnects the underlying Connection.
disconnect in interface ClientConnectionIOException - if there was a synchronous problem closing
the connection
public void sendMessage(ByteBuffer message)
throws IOException
The specified byte buffer must not be modified after invoking this method; otherwise this method may have unpredictable results.
sendMessage in interface ClientConnectionmessage - the message data to send
IOException - if there was a synchronous problem sending
the messagepublic void connected(Connection conn)
Connector or passively
by an Acceptor. This indicates that the connection is
ready for use, and data may be sent and received on it.
This implementation notifies the associated
ClientConnectionListener.
connected in interface ConnectionListenerconn - the Connection that has become connected.public void disconnected(Connection conn)
Connector fails to connect).
This implementation notifies the associated
ClientConnectionListener.
disconnected in interface ConnectionListenerconn - the Connection that has disconnected
public void exceptionThrown(Connection conn,
Throwable exception)
exceptionThrown in interface ConnectionListenerconn - the Connection on which the exception occuredexception - the thrown exception
public void bytesReceived(Connection conn,
byte[] message)
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.
This implementation forwards the message to the
associated ClientConnectionListener.
bytesReceived in interface ConnectionListenerconn - the Connection on which the message arrivedmessage - the received message bytes
|
Project Darkstar, Version 0.9.10.5 2013-07-29 21:14:44 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||