|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
A handle which represents connection between two endpoints regardless of transport types.
IoSession
provides user-defined attributes. User-defined attributes
are application-specific data which is associated with a session.
It often contains objects that represents the state of a higher-level protocol
and becomes a way to exchange data between filters and handlers.
You can simply downcast the session to an appropriate subclass.
IoSession
is thread-safe. But please note that performing
more than one write(Object)
calls at the same time will
cause the IoFilter.filterWrite(IoFilter.NextFilter, IoSession, IoFilter.WriteRequest)
is executed simnutaneously, and therefore you have to make sure the
IoFilter
implementations you're using are thread-safe, too.
Method Summary | |
CloseFuture |
close()
Closes this session immediately. |
boolean |
containsAttribute(String key)
Returns true if this session contains the attribute with the specified key. |
Object |
getAttachment()
Returns an attachment of this session. |
Object |
getAttribute(String key)
Returns the value of user-defined attribute of this session. |
Set |
getAttributeKeys()
Returns the set of keys of all user-defined attributes. |
CloseFuture |
getCloseFuture()
Returns the CloseFuture of this session. |
IoSessionConfig |
getConfig()
Returns the configuration of this session. |
long |
getCreationTime()
Returns the time in millis when this session is created. |
IoFilterChain |
getFilterChain()
Returns the filter chain that only affects this session. |
IoHandler |
getHandler()
Returns the IoHandler which handles this session. |
int |
getIdleCount(IdleStatus status)
Returns the number of the fired continuous sessionIdle events for the specified IdleStatus . |
int |
getIdleTime(IdleStatus status)
Returns idle time for the specified type of idleness in seconds. |
long |
getIdleTimeInMillis(IdleStatus status)
Returns idle time for the specified type of idleness in milliseconds. |
long |
getLastIdleTime(IdleStatus status)
Returns the time in millis when the last sessionIdle event is fired for the specified IdleStatus . |
long |
getLastIoTime()
Returns the time in millis when I/O occurred lastly. |
long |
getLastReadTime()
Returns the time in millis when read operation occurred lastly. |
long |
getLastWriteTime()
Returns the time in millis when write operation occurred lastly. |
SocketAddress |
getLocalAddress()
Returns the socket address of local machine which is associated with this session. |
long |
getReadBytes()
Returns the total number of bytes which were read from this session. |
long |
getReadMessages()
Returns the total number of messages which were read and decoded from this session. |
SocketAddress |
getRemoteAddress()
Returns the socket address of remote peer. |
int |
getScheduledWriteBytes()
Returns the number of bytes which are scheduled to be written to this session. |
int |
getScheduledWriteRequests()
Returns the number of write requests which are scheduled to be written to this session. |
IoService |
getService()
Returns the IoService which provides I/O service to this session. |
SocketAddress |
getServiceAddress()
Returns the socket address of the IoService listens to to manage
this session. |
IoServiceConfig |
getServiceConfig()
Returns the IoServiceConfig of this session. |
TrafficMask |
getTrafficMask()
Returns the current TrafficMask of this session. |
TransportType |
getTransportType()
Returns transport type of this session. |
int |
getWriteTimeout()
Returns write timeout in seconds. |
long |
getWriteTimeoutInMillis()
Returns write timeout in milliseconds. |
long |
getWrittenBytes()
Returns the total number of bytes which were written to this session. |
long |
getWrittenMessages()
Returns the total number of messages which were written and encoded by this session. |
long |
getWrittenWriteRequests()
Returns the total number of write requests which were written to this session. |
boolean |
isClosing()
Returns true if and only if this session is being closed
(but not disconnected yet) or is closed. |
boolean |
isConnected()
Returns true if this session is connected with remote peer. |
boolean |
isIdle(IdleStatus status)
Returns true if this session is idle for the specified
IdleStatus . |
Object |
removeAttribute(String key)
Removes a user-defined attribute with the specified key. |
void |
resumeRead()
A shortcut method for setTrafficMask(TrafficMask) that
resumes read operations for this session. |
void |
resumeWrite()
A shortcut method for setTrafficMask(TrafficMask) that
resumes write operations for this session. |
Object |
setAttachment(Object attachment)
Sets an attachment of this session. |
Object |
setAttribute(String key)
Sets a user defined attribute without a value. |
Object |
setAttribute(String key,
Object value)
Sets a user-defined attribute. |
void |
setIdleTime(IdleStatus status,
int idleTime)
Sets idle time for the specified type of idleness in seconds. |
void |
setTrafficMask(TrafficMask trafficMask)
Sets the TrafficMask of this session which will result
the parent IoService to start to control the traffic
of this session immediately. |
void |
setWriteTimeout(int writeTimeout)
Sets write timeout in seconds. |
void |
suspendRead()
A shortcut method for setTrafficMask(TrafficMask) that
suspends read operations for this session. |
void |
suspendWrite()
A shortcut method for setTrafficMask(TrafficMask) that
suspends write operations for this session. |
WriteFuture |
write(Object message)
Writes the specified message to remote peer. |
Method Detail |
public IoService getService()
IoService
which provides I/O service to this session.
public IoServiceConfig getServiceConfig()
IoServiceConfig
of this session.
public IoHandler getHandler()
IoHandler
which handles this session.
public IoSessionConfig getConfig()
public IoFilterChain getFilterChain()
public WriteFuture write(Object message)
message
to remote peer. This
operation is asynchronous; IoHandler.messageSent(IoSession, Object)
will be invoked when the message is actually sent to remote peer.
You can also wait for the returned WriteFuture
if you want
to wait for the message actually written.
public CloseFuture close()
CloseFuture
if you want to wait for
the session actually closed.
public Object getAttachment()
public Object setAttachment(Object attachment)
public Object getAttribute(String key)
key
- the key of the attribute
public Object setAttribute(String key, Object value)
key
- the key of the attributevalue
- the value of the attribute
public Object setAttribute(String key)
Boolean.TRUE
.
key
- the key of the attribute
public Object removeAttribute(String key)
public boolean containsAttribute(String key)
public Set getAttributeKeys()
public TransportType getTransportType()
public boolean isConnected()
true
if this session is connected with remote peer.
public boolean isClosing()
true if and only if this session is being closed
(but not disconnected yet) or is closed.
public CloseFuture getCloseFuture()
CloseFuture
of this session. This method returns
the same instance whenever user calls it.
public SocketAddress getRemoteAddress()
public SocketAddress getLocalAddress()
public SocketAddress getServiceAddress()
IoService
listens to to manage
this session. If this session is managed by IoAcceptor
, it
returns the SocketAddress
which is specified as a parameter of
IoAcceptor.bind(SocketAddress, IoHandler)
. If this session is
managed by IoConnector
, this method returns the same address with
that of getRemoteAddress()
.
public int getIdleTime(IdleStatus status)
public long getIdleTimeInMillis(IdleStatus status)
public void setIdleTime(IdleStatus status, int idleTime)
public int getWriteTimeout()
public long getWriteTimeoutInMillis()
public void setWriteTimeout(int writeTimeout)
public TrafficMask getTrafficMask()
TrafficMask
of this session.
public void setTrafficMask(TrafficMask trafficMask)
TrafficMask
of this session which will result
the parent IoService
to start to control the traffic
of this session immediately.
public void suspendRead()
setTrafficMask(TrafficMask)
that
suspends read operations for this session.
public void suspendWrite()
setTrafficMask(TrafficMask)
that
suspends write operations for this session.
public void resumeRead()
setTrafficMask(TrafficMask)
that
resumes read operations for this session.
public void resumeWrite()
setTrafficMask(TrafficMask)
that
resumes write operations for this session.
public long getReadBytes()
public long getWrittenBytes()
public long getReadMessages()
public long getWrittenMessages()
public long getWrittenWriteRequests()
public int getScheduledWriteRequests()
public int getScheduledWriteBytes()
public long getCreationTime()
public long getLastIoTime()
public long getLastReadTime()
public long getLastWriteTime()
public boolean isIdle(IdleStatus status)
true
if this session is idle for the specified
IdleStatus
.
public int getIdleCount(IdleStatus status)
IdleStatus
.
If sessionIdle event is fired first after some time after I/O, idleCount becomes 1. idleCount resets to 0 if any I/O occurs again, otherwise it increases to 2 and so on if sessionIdle event is fired again without any I/O between two (or more) sessionIdle events.
public long getLastIdleTime(IdleStatus status)
IdleStatus
.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |