public class Nio2Session extends AbstractCloseable implements IoSession
AbstractCloseable.State| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_READBUF_SIZE |
closeFuture, lock, statelogCLOSE_WAIT_TIMEOUT, DEFAULT_CLOSE_WAIT_TIMEOUT| Constructor and Description |
|---|
Nio2Session(Nio2Service service,
FactoryManager manager,
IoHandler handler,
AsynchronousSocketChannel socket) |
addCloseFutureListener, builder, close, isClosed, isClosing, preClose, removeCloseFutureListenergetSimplifiedLoggerclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitaddCloseFutureListener, close, close, getMaxCloseWaitTime, isClosed, isClosing, isOpen, removeCloseFutureListenerpublic static final int DEFAULT_READBUF_SIZE
public Nio2Session(Nio2Service service, FactoryManager manager, IoHandler handler, AsynchronousSocketChannel socket) throws IOException
IOExceptionpublic long getId()
public Object getAttribute(Object key)
IoSessiongetAttribute in interface IoSessionkey - the key of the attributepublic Object setAttribute(Object key, Object value)
IoSessionsetAttribute in interface IoSessionkey - the key of the attributevalue - the value of the attributepublic SocketAddress getRemoteAddress()
getRemoteAddress in interface IoSessionpublic SocketAddress getLocalAddress()
getLocalAddress in interface IoSessionpublic AsynchronousSocketChannel getSocket()
public IoHandler getIoHandler()
public void suspend()
public IoWriteFuture write(Buffer buffer)
IoSessionwrite in interface IoSessionbuffer - The Buffer with the encoded packet dataIoWriteFuture for the requestprotected void exceptionCaught(Throwable exc)
protected CloseFuture doCloseGracefully()
doCloseGracefully in class AbstractCloseableprotected void doCloseImmediately()
AbstractCloseabledoCloseImmediately is called once and only once with state == Immediate
Overriding methods should always call the base implementation. It may be called concurrently while preClose() or doCloseGracefully is executing
doCloseImmediately in class AbstractCloseablepublic Nio2Service getService()
getService in interface IoSessionIoService that created this session.public void startReading()
public void startReading(int bufSize)
public void startReading(byte[] buf)
public void startReading(byte[] buf,
int offset,
int len)
public void startReading(ByteBuffer buffer)
protected void doReadCycle(ByteBuffer buffer, Readable bufReader)
protected Nio2CompletionHandler<Integer,Object> createReadCycleCompletionHandler(ByteBuffer buffer, Readable bufReader)
protected void handleReadCycleCompletion(ByteBuffer buffer, Readable bufReader, Nio2CompletionHandler<Integer,Object> completionHandler, Integer result, Object attachment)
protected void handleReadCycleFailure(ByteBuffer buffer, Readable bufReader, Throwable exc, Object attachment)
protected void doReadCycle(ByteBuffer buffer, Nio2CompletionHandler<Integer,Object> completion)
protected void startWriting()
protected void doWriteCycle(ByteBuffer buffer, Nio2CompletionHandler<Integer,Object> completion)
protected Nio2CompletionHandler<Integer,Object> createWriteCycleCompletionHandler(Nio2DefaultIoWriteFuture future, AsynchronousSocketChannel socket, ByteBuffer buffer)
protected void handleCompletedWriteCycle(Nio2DefaultIoWriteFuture future, AsynchronousSocketChannel socket, ByteBuffer buffer, int writeLen, Nio2CompletionHandler<Integer,Object> completionHandler, Integer result, Object attachment)
protected void handleWriteCycleFailure(Nio2DefaultIoWriteFuture future, AsynchronousSocketChannel socket, ByteBuffer buffer, int writeLen, Throwable exc, Object attachment)
protected void finishWrite(Nio2DefaultIoWriteFuture future)
Copyright © 2008–2017 The Apache Software Foundation. All rights reserved.