public class Nio2Session extends AbstractCloseable implements IoSession
AbstractCloseable.State
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_READBUF_SIZE |
closeFuture, lock, state
log
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, preClose
close, isOpen
public static final int DEFAULT_READBUF_SIZE
public Nio2Session(Nio2Service service, FactoryManager manager, IoHandler handler, AsynchronousSocketChannel socket) throws IOException
IOException
public long getId()
public Object getAttribute(Object key)
IoSession
getAttribute
in interface IoSession
key
- the key of the attributepublic Object setAttribute(Object key, Object value)
IoSession
setAttribute
in interface IoSession
key
- the key of the attributevalue
- the value of the attributepublic SocketAddress getRemoteAddress()
getRemoteAddress
in interface IoSession
public SocketAddress getLocalAddress()
getLocalAddress
in interface IoSession
public void suspend()
public IoWriteFuture write(Buffer buffer)
IoSession
write
in interface IoSession
buffer
- The Buffer
with the encoded packet dataIoWriteFuture
for the requestprotected CloseFuture doCloseGracefully()
doCloseGracefully
in class AbstractCloseable
protected void doCloseImmediately()
AbstractCloseable
doCloseImmediately 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 AbstractCloseable
public IoService getService()
getService
in interface IoSession
IoService
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–2016 The Apache Software Foundation. All rights reserved.