public interface INioSession extends Serializable, Closeable
Modifier and Type | Interface and Description |
---|---|
static class |
INioSession.Status
会话状态枚举
|
Modifier and Type | Method and Description |
---|---|
<T> T |
attr(String key)
获取指定键名的属性值
|
void |
attr(String key,
Object value)
添加属性
|
Map<String,Object> |
attrs()
获取属性映射
|
void |
closeNow()
立即关闭
|
boolean |
connectSync(long time)
等待连接指定time时间
|
void |
finishConnect()
结束等待连接
|
String |
id()
获取会话唯一标识
|
boolean |
isConnected()
判断会话状态是否为CONNECTED
|
boolean |
isNew()
判断会话状态是否为NEW
|
boolean |
isUdp()
判断是否为UDP会话
|
long |
lastTouchTime()
获取最后更新会话状态的时间(毫秒)
|
void |
read()
从会话读取数据
|
void |
registerEvent(int ops)
注册事件
|
String |
remoteAddress()
获取远程IP地址端口号
|
InetSocketAddress |
remoteSocketAddress()
获取远程套接字地址对象
|
SelectionKey |
selectionKey()
获取选择键
|
void |
selectionKey(SelectionKey key)
设置选择键
|
void |
send(Object message)
向会话发送消息
|
INioSession.Status |
status()
获取当前会话状态
|
void |
status(INioSession.Status status)
设置当前会话状态
|
void |
touch()
更新会话活动状态
|
void |
write()
向会话写入数据
|
String id()
boolean isNew()
boolean isConnected()
InetSocketAddress remoteSocketAddress()
String remoteAddress()
INioSession.Status status()
void touch()
long lastTouchTime()
<T> T attr(String key)
T
- 键值类型key
- 键名void send(Object message) throws IOException
message
- 消息对象IOException
- 可能产生的异常void registerEvent(int ops) throws IOException
ops
- 事件参数IOException
- 可能产生的异常void selectionKey(SelectionKey key)
key
- 选择键SelectionKey selectionKey()
boolean connectSync(long time)
time
- 等待时间(毫秒)void finishConnect()
boolean isUdp()
void status(INioSession.Status status)
status
- 会话状态对象void closeNow() throws IOException
IOException
- 可能产生的I/O异常void read() throws IOException
IOException
- 可能产生的I/O异常void write() throws IOException
IOException
- 可能产生的I/O异常Copyright © 2022. All rights reserved.