public class AioSession extends Object implements Closeable
Constructor and Description |
---|
AioSession(AsynchronousSocketChannel channel,
IoAction<ByteBuffer> ioAction,
SocketConfig config)
构造
|
Modifier and Type | Method and Description |
---|---|
protected void |
callbackRead()
执行读,用于读取事件结束的回调
|
void |
close()
关闭会话
|
AioSession |
closeIn()
关闭输出
|
AioSession |
closeOut()
关闭输出
|
AsynchronousSocketChannel |
getChannel()
|
IoAction<ByteBuffer> |
getIoAction()
获取消息处理器
|
ByteBuffer |
getReadBuffer()
获取读取Buffer
|
SocketAddress |
getRemoteAddress()
获取远程主机(客户端)地址和端口
|
ByteBuffer |
getWriteBuffer()
获取写Buffer
|
boolean |
isOpen()
会话是否打开状态
当Socket保持连接时会话始终打开 |
AioSession |
read()
读取数据到Buffer
|
AioSession |
read(CompletionHandler<Integer,AioSession> handler)
读取数据到Buffer
|
Future<Integer> |
write(ByteBuffer data)
写数据到目标端
|
AioSession |
write(ByteBuffer data,
CompletionHandler<Integer,AioSession> handler)
写数据到目标端
|
AioSession |
writeAndClose(ByteBuffer data)
写数据到目标端,并关闭输出
|
public AioSession(AsynchronousSocketChannel channel, IoAction<ByteBuffer> ioAction, SocketConfig config)
channel
- AsynchronousSocketChannel
ioAction
- IO消息处理类config
- 配置项public AsynchronousSocketChannel getChannel()
AsynchronousSocketChannel
public ByteBuffer getReadBuffer()
public ByteBuffer getWriteBuffer()
public IoAction<ByteBuffer> getIoAction()
IoAction
public SocketAddress getRemoteAddress()
public AioSession read()
public AioSession read(CompletionHandler<Integer,AioSession> handler)
handler
- CompletionHandler
public AioSession writeAndClose(ByteBuffer data)
data
- 数据public Future<Integer> write(ByteBuffer data)
data
- 数据Future
public AioSession write(ByteBuffer data, CompletionHandler<Integer,AioSession> handler)
data
- 数据handler
- CompletionHandler
public boolean isOpen()
public AioSession closeIn()
public AioSession closeOut()
public void close()
close
in interface Closeable
close
in interface AutoCloseable
protected void callbackRead()
Copyright © 2024. All rights reserved.