public class TcpAioSession<T> extends AioSession
AioSession为bus-socket最核心的类,封装AsynchronousSocketChannel API接口,简化IO操作
其中开放给用户使用的接口为:
SESSION_STATUS_CLOSED, SESSION_STATUS_CLOSING, SESSION_STATUS_ENABLED, status| Modifier and Type | Method and Description |
|---|---|
void |
close(boolean immediate)
是否立即关闭会话
|
InputStream |
getInputStream()
获得数据输入流对象。
|
InputStream |
getInputStream(int length)
获取已知长度的InputStream
|
InetSocketAddress |
getLocalAddress()
获取当前会话的本地连接地址
|
InetSocketAddress |
getRemoteAddress()
获取当前会话的远程连接地址
|
ServerConfig<T> |
getServerConfig() |
String |
getSessionID()
获取当前Session的唯一标识
|
boolean |
isInvalid()
当前会话是否已失效
|
void |
readCompleted(boolean eof)
触发通道的读回调操作
|
org.aoju.bus.core.io.WriteBuffer |
writeBuffer()
获取WriteBuffer用以数据输出
|
void |
writeCompleted()
触发AIO的写操作,
需要调用控制同步
|
close, getAttachment, setAttachmentpublic void writeCompleted()
public final org.aoju.bus.core.io.WriteBuffer writeBuffer()
AioSessionwriteBuffer in class AioSessionpublic void close(boolean immediate)
close in class AioSessionimmediate - true:立即关闭,false:响应消息发送完后关闭public final String getSessionID()
getSessionID in class AioSessionpublic final boolean isInvalid()
isInvalid in class AioSessionpublic void readCompleted(boolean eof)
eof - 输入流是否已关闭public final InetSocketAddress getLocalAddress() throws IOException
AioSessiongetLocalAddress in class AioSessionIOException - IO异常AsynchronousSocketChannel.getLocalAddress()public final InetSocketAddress getRemoteAddress() throws IOException
AioSessiongetRemoteAddress in class AioSessionIOException - IO异常AsynchronousSocketChannel.getRemoteAddress()public ServerConfig<T> getServerConfig()
public final InputStream getInputStream() throws IOException
faster模式下调用该方法会触发UnsupportedOperationException异常 MessageProcessor采用异步处理消息的方式时,调用该方法可能会出现异常
getInputStream in class AioSessionIOException - io异常public final InputStream getInputStream(int length) throws IOException
getInputStream in class AioSessionlength - InputStream长度IOException - io异常Copyright © 2021. All rights reserved.