LISTENER - 监听器类型public abstract class AbstractNioSession<LISTENER extends IListener<INioSession>> extends Object implements INioSession
INioSession.Status| Constructor and Description |
|---|
AbstractNioSession(INioEventGroup<LISTENER> eventGroup,
SelectableChannel channel) |
| Modifier and Type | Method and Description |
|---|---|
<T> T |
attr(String key)
获取指定键名的属性值
|
void |
attr(String key,
Object value)
添加属性
|
Map<String,Object> |
attrs()
获取属性映射
|
protected ByteBufferBuilder |
buffer() |
protected void |
buffer(ByteBufferBuilder bufferBuilder) |
protected void |
bufferReset(ByteBufferBuilder buffer) |
protected SelectableChannel |
channel() |
void |
close() |
void |
closeNow()
立即关闭
|
boolean |
connectSync(long time)
等待连接指定time时间
|
boolean |
equals(Object o) |
protected INioEventGroup<LISTENER> |
eventGroup() |
void |
finishConnect()
结束等待连接
|
int |
hashCode() |
String |
id()
获取会话唯一标识
|
boolean |
isConnected()
判断会话状态是否为CONNECTED
|
boolean |
isNew()
判断会话状态是否为NEW
|
boolean |
isUdp()
判断是否为UDP会话
|
long |
lastTouchTime()
获取最后更新会话状态的时间(毫秒)
|
protected void |
postMessageReceived(Object message) |
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)
设置当前会话状态
|
String |
toString() |
void |
touch()
更新会话活动状态
|
void |
write()
向会话写入数据
|
public AbstractNioSession(INioEventGroup<LISTENER> eventGroup, SelectableChannel channel)
public String id()
INioSessionid in interface INioSessionpublic boolean isNew()
INioSessionisNew in interface INioSessionpublic boolean isConnected()
INioSessionisConnected in interface INioSessionpublic void touch()
INioSessiontouch in interface INioSessionpublic long lastTouchTime()
INioSessionlastTouchTime in interface INioSessionpublic Map<String,Object> attrs()
INioSessionattrs in interface INioSessionpublic <T> T attr(String key)
INioSessionattr in interface INioSessionT - 键值类型key - 键名public void attr(String key, Object value)
INioSessionattr in interface INioSessionkey - 键名value - 键值protected INioEventGroup<LISTENER> eventGroup()
protected SelectableChannel channel()
protected ByteBufferBuilder buffer()
protected void buffer(ByteBufferBuilder bufferBuilder)
public boolean isUdp()
INioSessionisUdp in interface INioSessionpublic InetSocketAddress remoteSocketAddress()
INioSessionremoteSocketAddress in interface INioSessionpublic String remoteAddress()
INioSessionremoteAddress in interface INioSessionpublic INioSession.Status status()
INioSessionstatus in interface INioSessionpublic void status(INioSession.Status status)
INioSessionstatus in interface INioSessionstatus - 会话状态对象public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionpublic void closeNow()
throws IOException
INioSessioncloseNow in interface INioSessionIOException - 可能产生的I/O异常public void registerEvent(int ops)
throws IOException
INioSessionregisterEvent in interface INioSessionops - 事件参数IOException - 可能产生的异常public void selectionKey(SelectionKey key)
INioSessionselectionKey in interface INioSessionkey - 选择键public SelectionKey selectionKey()
INioSessionselectionKey in interface INioSessionpublic boolean connectSync(long time)
INioSessionconnectSync in interface INioSessiontime - 等待时间(毫秒)public void finishConnect()
INioSessionfinishConnect in interface INioSessionprotected void bufferReset(ByteBufferBuilder buffer)
protected void postMessageReceived(Object message)
public void read()
throws IOException
INioSessionread in interface INioSessionIOException - 可能产生的I/O异常public void write()
throws IOException
INioSessionwrite in interface INioSessionIOException - 可能产生的I/O异常public void send(Object message)
INioSessionsend in interface INioSessionmessage - 消息对象Copyright © 2022. All rights reserved.