|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.threerings.nio.conman.Connection
public abstract class Connection
Implements the net event handler interface to check for delinquency and manages a client
connection. Subclasses must handle incoming data in NetEventHandler.handleEvent(long).
| Field Summary | |
|---|---|
protected SocketChannel |
_channel
|
protected ConnectionManager |
_cmgr
|
protected int |
_connectionId
|
protected static int |
_lastConnectionId
The last connection id assigned. |
protected long |
_lastEvent
|
SelectionKey |
selkey
The key used by the NIO code to track this connection. |
| Constructor Summary | |
|---|---|
Connection()
|
|
| Method Summary | |
|---|---|
void |
asyncClose()
Queues up a request to have this connection closed by the connection manager once all messages in its queue have been written to its target. |
void |
becameIdle()
Called if the handler is deemed to be idle. |
boolean |
checkIdle(long idleStamp)
Called to ensure that this channel has not been idle for longer than is possible in happily operating circumstances. |
void |
close()
Closes this connection and unregisters it from the connection manager. |
protected void |
closeSocket()
Closes the socket associated with this connection. |
void |
connectFailure(IOException ioe)
Called when an outgoing socket experiences a connect failure. |
SocketChannel |
getChannel()
Returns the non-blocking socket object used to construct this connection. |
int |
getConnectionId()
Returns the connection's unique identifier. |
InetAddress |
getInetAddress()
Returns the address associated with this connection or null if it has no underlying socket channel. |
void |
init(ConnectionManager cmgr,
SocketChannel channel,
long createStamp)
Initializes a connection object with a socket and related info. |
boolean |
isClosed()
Returns true if this connection is closed. |
void |
networkFailure(IOException ioe)
Called when there is a failure reading or writing to this connection. |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface com.threerings.nio.conman.NetEventHandler |
|---|
handleEvent |
| Field Detail |
|---|
public SelectionKey selkey
protected ConnectionManager _cmgr
protected SocketChannel _channel
protected long _lastEvent
protected int _connectionId
protected static int _lastConnectionId
| Constructor Detail |
|---|
public Connection()
| Method Detail |
|---|
public void init(ConnectionManager cmgr,
SocketChannel channel,
long createStamp)
throws IOException
cmgr - The connection manager with which this connection is associated.channel - The socket channel from which we'll be reading messages.createStamp - The time at which this connection was created.
IOExceptionpublic int getConnectionId()
public SocketChannel getChannel()
public InetAddress getInetAddress()
public boolean isClosed()
public void close()
public void asyncClose()
public void connectFailure(IOException ioe)
public void networkFailure(IOException ioe)
public boolean checkIdle(long idleStamp)
NetEventHandler
checkIdle in interface NetEventHandleridleStamp - if the handler's last event occurred more recently than this timestamp, it
should return false, otherwise true.
public void becameIdle()
NetEventHandler
becameIdle in interface NetEventHandlerpublic String toString()
toString in class Objectprotected void closeSocket()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||