@ThreadSafe public class IOSessionImpl extends java.lang.Object implements IOSession, SocketAccessor
IOSession.ACTIVE, ATTACHMENT_KEY, CLOSED, CLOSING| 构造器和说明 |
|---|
IOSessionImpl(java.nio.channels.SelectionKey key,
depends.org.apache.http.impl.nio.reactor.InterestOpsCallback interestOpsCallback,
SessionClosedCallback sessionClosedCallback)
Creates new instance of IOSessionImpl.
|
IOSessionImpl(java.nio.channels.SelectionKey key,
SessionClosedCallback sessionClosedCallback)
Creates new instance of IOSessionImpl.
|
| 限定符和类型 | 方法和说明 |
|---|---|
java.nio.channels.ByteChannel |
channel()
Returns the underlying I/O channel associated with this session.
|
void |
clearEvent(int op)
Clears interest in a particular I/O event category by updating the event
mask associated with the session.
|
void |
close()
Terminates the session gracefully and closes the underlying I/O channel.
|
java.lang.Object |
getAttribute(java.lang.String name)
Returns the value of the attribute with the given name.
|
int |
getEventMask()
Returns mask of I/O evens this session declared interest in.
|
long |
getLastAccessTime() |
long |
getLastReadTime() |
long |
getLastWriteTime() |
java.net.SocketAddress |
getLocalAddress()
Returns local address.
|
java.net.SocketAddress |
getRemoteAddress()
Returns address of the remote peer.
|
java.net.Socket |
getSocket()
Return the underlying socket
|
int |
getSocketTimeout()
Returns value of the socket timeout in milliseconds.
|
long |
getStartedTime() |
int |
getStatus()
Returns status of the session:
IOSession.ACTIVE: session is active. |
boolean |
hasBufferedInput()
Determines if the input buffer associated with the session contains data.
|
boolean |
hasBufferedOutput()
Determines if the output buffer associated with the session contains
data.
|
boolean |
isClosed()
Determines if the session has been terminated.
|
java.lang.Object |
removeAttribute(java.lang.String name)
Removes attribute with the given name.
|
void |
setAttribute(java.lang.String name,
java.lang.Object obj)
This method can be used to associate a particular object with the
session by the given attribute name.
|
void |
setBufferStatus(SessionBufferStatus bufferStatus)
Quite often I/O sessions need to maintain internal I/O buffers in order
to transform input / output data prior to returning it to the consumer or
writing it to the underlying channel.
|
void |
setEvent(int op)
Declares interest in a particular I/O event category by updating the event
mask associated with the session.
|
void |
setEventMask(int ops)
Declares interest in I/O event notifications by setting the event mask
associated with the session
|
void |
setSocketTimeout(int timeout)
Sets value of the socket timeout in milliseconds.
|
void |
shutdown()
Terminates the session by shutting down the underlying I/O channel.
|
java.lang.String |
toString() |
public IOSessionImpl(java.nio.channels.SelectionKey key,
depends.org.apache.http.impl.nio.reactor.InterestOpsCallback interestOpsCallback,
SessionClosedCallback sessionClosedCallback)
key - the selection key.interestOpsCallback - interestOps callback.sessionClosedCallback - session closed callback.public IOSessionImpl(java.nio.channels.SelectionKey key,
SessionClosedCallback sessionClosedCallback)
key - the selection key.sessionClosedCallback - session closed callback.public java.nio.channels.ByteChannel channel()
IOSessionpublic java.net.SocketAddress getLocalAddress()
IOSessiongetLocalAddress 在接口中 IOSessionpublic java.net.SocketAddress getRemoteAddress()
IOSessiongetRemoteAddress 在接口中 IOSessionpublic int getEventMask()
IOSessiongetEventMask 在接口中 IOSessionpublic void setEventMask(int ops)
IOSessionsetEventMask 在接口中 IOSessionops - new I/O event mask.public void setEvent(int op)
IOSessionpublic void clearEvent(int op)
IOSessionclearEvent 在接口中 IOSessionop - I/O event category.public int getSocketTimeout()
IOSession0 signifies the session cannot time out.getSocketTimeout 在接口中 IOSessionpublic void setSocketTimeout(int timeout)
IOSession0 signifies the session cannot time out.setSocketTimeout 在接口中 IOSessiontimeout - socket timeout.public void close()
IOSessionpublic int getStatus()
IOSession
IOSession.ACTIVE: session is active.
IOSession.CLOSING: session is being closed.
IOSession.CLOSED: session has been terminated.
public boolean isClosed()
IOSessionpublic void shutdown()
IOSessionpublic boolean hasBufferedInput()
IOSessionhasBufferedInput 在接口中 IOSessiontrue if the session input buffer contains data,
false otherwise.public boolean hasBufferedOutput()
IOSessionhasBufferedOutput 在接口中 IOSessiontrue if the session output buffer contains data,
false otherwise.public void setBufferStatus(SessionBufferStatus bufferStatus)
IOSession
I/O sessions can be made aware of the status of external session buffers
using the SessionBufferStatus interface.
setBufferStatus 在接口中 IOSessionpublic java.lang.Object getAttribute(java.lang.String name)
IOSessionnull if not set.
The value of the session attachment object can be obtained using
IOSession.ATTACHMENT_KEY name.
getAttribute 在接口中 IOSessionname - name of the attribute.IOSession.setAttribute(String, Object)public java.lang.Object removeAttribute(java.lang.String name)
IOSessionremoveAttribute 在接口中 IOSessionname - name of the attribute to be removed.IOSession.setAttribute(String, Object)public void setAttribute(java.lang.String name,
java.lang.Object obj)
IOSessionI/O sessions are not bound to an execution thread, therefore one cannot use the context of the thread to store a session's state. All details about a particular session must be stored within the session itself.
setAttribute 在接口中 IOSessionname - name of the attribute.obj - value of the attribute.public long getStartedTime()
public long getLastReadTime()
public long getLastWriteTime()
public long getLastAccessTime()
public java.lang.String toString()
toString 在类中 java.lang.Objectpublic java.net.Socket getSocket()
SocketAccessorgetSocket 在接口中 SocketAccessornull.