public abstract class Connection extends Object implements NetEventHandler
NetEventHandler.handleEvent(long).| Modifier and Type | Field and Description |
|---|---|
SelectionKey |
selkey
The key used by the NIO code to track this connection.
|
| Constructor and Description |
|---|
Connection() |
| Modifier and Type | Method and Description |
|---|---|
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.
|
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() |
equals, getClass, hashCode, notify, notifyAll, wait, wait, waithandleEventpublic SelectionKey selkey
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)
NetEventHandlercheckIdle in interface NetEventHandleridleStamp - if the handler's last event occurred more recently than this timestamp, it
should return false, otherwise true.public void becameIdle()
NetEventHandlerbecameIdle in interface NetEventHandlerCopyright © 2015. All rights reserved.