public abstract class BaseIoSession extends java.lang.Object implements IoSession
IoSession
.限定符 | 构造器和说明 |
---|---|
protected |
BaseIoSession() |
限定符和类型 | 方法和说明 |
---|---|
CloseFuture |
close()
Closes this session immediately.
|
protected void |
close0()
Implement this method to perform real close operation.
|
boolean |
containsAttribute(java.lang.String key)
Returns true if this session contains the attribute with
the specified key.
|
java.lang.Object |
getAttachment()
Returns an attachment of this session.
|
java.lang.Object |
getAttribute(java.lang.String key)
Returns the value of user-defined attribute of this session.
|
java.util.Set<java.lang.String> |
getAttributeKeys()
Returns the set of keys of all user-defined attributes.
|
CloseFuture |
getCloseFuture()
Returns the
CloseFuture of this session. |
long |
getCreationTime()
Returns the time in millis when this session is created.
|
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.
|
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.
|
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.
|
TrafficMask |
getTrafficMask()
Returns the current
TrafficMask 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.
|
void |
increaseIdleCount(IdleStatus status) |
void |
increaseReadBytes(int increment) |
void |
increaseReadMessages() |
void |
increaseScheduledWriteBytes(int increment) |
void |
increaseScheduledWriteRequests() |
void |
increaseWrittenBytes(int increment) |
void |
increaseWrittenMessages() |
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 . |
boolean |
isScheduledForFlush() |
java.lang.Object |
removeAttribute(java.lang.String key)
Removes a user-defined attribute with the specified key.
|
void |
resumeRead()
A shortcut method for
IoSession.setTrafficMask(TrafficMask) that
resumes read operations for this session. |
void |
resumeWrite()
A shortcut method for
IoSession.setTrafficMask(TrafficMask) that
resumes write operations for this session. |
java.lang.Object |
setAttachment(java.lang.Object attachment)
Sets an attachment of this session.
|
java.lang.Object |
setAttribute(java.lang.String key)
Sets a user defined attribute without a value.
|
java.lang.Object |
setAttribute(java.lang.String key,
java.lang.Object value)
Sets a user-defined attribute.
|
void |
setIdleTime(IdleStatus status,
int idleTime)
Sets idle time for the specified type of idleness in seconds.
|
boolean |
setScheduledForFlush(boolean flag) |
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
IoSession.setTrafficMask(TrafficMask) that
suspends read operations for this session. |
void |
suspendWrite()
A shortcut method for
IoSession.setTrafficMask(TrafficMask) that
suspends write operations for this session. |
java.lang.String |
toString() |
protected abstract void |
updateTrafficMask()
Signals the
IoService that the TrafficMask of this
session has been changed. |
WriteFuture |
write(java.lang.Object message)
Writes the specified
message to remote peer. |
WriteFuture |
write(java.lang.Object message,
java.net.SocketAddress remoteAddress) |
protected void |
write0(IoFilter.WriteRequest writeRequest)
Implement this method to perform real write operation with
the specified
writeRequest . |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getConfig, getFilterChain, getHandler, getLocalAddress, getRemoteAddress, getService, getServiceAddress, getServiceConfig, getTransportType
public boolean isConnected()
IoSession
true
if this session is connected with remote peer.isConnected
在接口中 IoSession
public boolean isClosing()
IoSession
true if and only if this session is being closed
(but not disconnected yet) or is closed.
public CloseFuture getCloseFuture()
IoSession
CloseFuture
of this session. This method returns
the same instance whenever user calls it.getCloseFuture
在接口中 IoSession
public boolean isScheduledForFlush()
public boolean setScheduledForFlush(boolean flag)
public CloseFuture close()
IoSession
CloseFuture
if you want to wait for
the session actually closed.protected void close0()
public WriteFuture write(java.lang.Object message)
IoSession
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 WriteFuture write(java.lang.Object message, java.net.SocketAddress remoteAddress)
protected void write0(IoFilter.WriteRequest writeRequest)
writeRequest
.
By default, this method is implemented to set the future to
'not written' immediately.writeRequest
- Write request to makepublic java.lang.Object getAttachment()
IoSession
getAttachment
在接口中 IoSession
public java.lang.Object setAttachment(java.lang.Object attachment)
IoSession
setAttachment
在接口中 IoSession
public java.lang.Object getAttribute(java.lang.String key)
IoSession
getAttribute
在接口中 IoSession
key
- the key of the attributepublic java.lang.Object setAttribute(java.lang.String key, java.lang.Object value)
IoSession
setAttribute
在接口中 IoSession
key
- the key of the attributevalue
- the value of the attributepublic java.lang.Object setAttribute(java.lang.String key)
IoSession
Boolean.TRUE
.setAttribute
在接口中 IoSession
key
- the key of the attributepublic java.lang.Object removeAttribute(java.lang.String key)
IoSession
removeAttribute
在接口中 IoSession
public boolean containsAttribute(java.lang.String key)
IoSession
containsAttribute
在接口中 IoSession
public java.util.Set<java.lang.String> getAttributeKeys()
IoSession
getAttributeKeys
在接口中 IoSession
public int getIdleTime(IdleStatus status)
IoSession
getIdleTime
在接口中 IoSession
public long getIdleTimeInMillis(IdleStatus status)
IoSession
getIdleTimeInMillis
在接口中 IoSession
public void setIdleTime(IdleStatus status, int idleTime)
IoSession
setIdleTime
在接口中 IoSession
public int getWriteTimeout()
IoSession
getWriteTimeout
在接口中 IoSession
public long getWriteTimeoutInMillis()
IoSession
getWriteTimeoutInMillis
在接口中 IoSession
public void setWriteTimeout(int writeTimeout)
IoSession
setWriteTimeout
在接口中 IoSession
public TrafficMask getTrafficMask()
IoSession
TrafficMask
of this session.getTrafficMask
在接口中 IoSession
public void setTrafficMask(TrafficMask trafficMask)
IoSession
TrafficMask
of this session which will result
the parent IoService
to start to control the traffic
of this session immediately.setTrafficMask
在接口中 IoSession
public void suspendRead()
IoSession
IoSession.setTrafficMask(TrafficMask)
that
suspends read operations for this session.suspendRead
在接口中 IoSession
public void suspendWrite()
IoSession
IoSession.setTrafficMask(TrafficMask)
that
suspends write operations for this session.suspendWrite
在接口中 IoSession
public void resumeRead()
IoSession
IoSession.setTrafficMask(TrafficMask)
that
resumes read operations for this session.resumeRead
在接口中 IoSession
public void resumeWrite()
IoSession
IoSession.setTrafficMask(TrafficMask)
that
resumes write operations for this session.resumeWrite
在接口中 IoSession
protected abstract void updateTrafficMask()
IoService
that the TrafficMask
of this
session has been changed.public long getReadBytes()
IoSession
getReadBytes
在接口中 IoSession
public long getWrittenBytes()
IoSession
getWrittenBytes
在接口中 IoSession
public long getWrittenWriteRequests()
IoSession
getWrittenWriteRequests
在接口中 IoSession
public long getReadMessages()
IoSession
getReadMessages
在接口中 IoSession
public long getWrittenMessages()
IoSession
getWrittenMessages
在接口中 IoSession
public int getScheduledWriteBytes()
IoSession
getScheduledWriteBytes
在接口中 IoSession
public int getScheduledWriteRequests()
IoSession
getScheduledWriteRequests
在接口中 IoSession
public void increaseReadBytes(int increment)
public void increaseWrittenBytes(int increment)
public void increaseReadMessages()
public void increaseWrittenMessages()
public void increaseScheduledWriteBytes(int increment)
public void increaseScheduledWriteRequests()
public long getCreationTime()
IoSession
getCreationTime
在接口中 IoSession
public long getLastIoTime()
IoSession
getLastIoTime
在接口中 IoSession
public long getLastReadTime()
IoSession
getLastReadTime
在接口中 IoSession
public long getLastWriteTime()
IoSession
getLastWriteTime
在接口中 IoSession
public boolean isIdle(IdleStatus status)
IoSession
true
if this session is idle for the specified
IdleStatus
.public int getIdleCount(IdleStatus status)
IoSession
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.
getIdleCount
在接口中 IoSession
public long getLastIdleTime(IdleStatus status)
IoSession
IdleStatus
.getLastIdleTime
在接口中 IoSession
public void increaseIdleCount(IdleStatus status)
public java.lang.String toString()
toString
在类中 java.lang.Object