public class Nio2Session extends CloseableUtils.AbstractCloseable implements IoSession
CloseableUtils.AbstractCloseable.State| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_READBUF_SIZE |
closeFuture, lock, statelog| Constructor and Description |
|---|
Nio2Session(Nio2Service service,
FactoryManager manager,
IoHandler handler,
AsynchronousSocketChannel socket) |
| Modifier and Type | Method and Description |
|---|---|
protected CloseFuture |
doCloseGracefully() |
protected void |
doCloseImmediately()
doCloseImmediately is called once and only once
with state == Immediate
|
protected void |
doReadCycle(ByteBuffer buffer,
Nio2CompletionHandler<Integer,Object> completion) |
protected void |
doReadCycle(ByteBuffer buffer,
Readable bufReader) |
Object |
getAttribute(Object key)
Returns the value of the user-defined attribute of this session.
|
long |
getId() |
SocketAddress |
getLocalAddress() |
SocketAddress |
getRemoteAddress() |
IoService |
getService() |
Object |
setAttribute(Object key,
Object value)
Sets a user-defined attribute.
|
void |
startReading() |
void |
startReading(byte[] buf) |
void |
startReading(byte[] buf,
int offset,
int len) |
void |
startReading(ByteBuffer buffer) |
void |
startReading(int bufSize) |
void |
suspend() |
String |
toString() |
IoWriteFuture |
write(Buffer buffer)
Write a packet on the socket.
|
builder, close, isClosed, isClosing, preCloseclose, isOpenpublic 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 void suspend()
public IoWriteFuture write(Buffer buffer)
IoSessionwrite in interface IoSessionbuffer - The Buffer with the encoded packet dataIoWriteFuture for the requestprotected CloseFuture doCloseGracefully()
doCloseGracefully in class CloseableUtils.AbstractCloseableprotected void doCloseImmediately()
CloseableUtils.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 CloseableUtils.AbstractCloseablepublic IoService 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 void doReadCycle(ByteBuffer buffer, Nio2CompletionHandler<Integer,Object> completion)
Copyright © 2008–2015 The Apache Software Foundation. All rights reserved.