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()
INioSession
id
in interface INioSession
public boolean isNew()
INioSession
isNew
in interface INioSession
public boolean isConnected()
INioSession
isConnected
in interface INioSession
public void touch()
INioSession
touch
in interface INioSession
public long lastTouchTime()
INioSession
lastTouchTime
in interface INioSession
public Map<String,Object> attrs()
INioSession
attrs
in interface INioSession
public <T> T attr(String key)
INioSession
attr
in interface INioSession
T
- 键值类型key
- 键名public void attr(String key, Object value)
INioSession
attr
in interface INioSession
key
- 键名value
- 键值protected INioEventGroup<LISTENER> eventGroup()
protected SelectableChannel channel()
protected ByteBufferBuilder buffer()
protected void buffer(ByteBufferBuilder bufferBuilder)
public boolean isUdp()
INioSession
isUdp
in interface INioSession
public InetSocketAddress remoteSocketAddress()
INioSession
remoteSocketAddress
in interface INioSession
public String remoteAddress()
INioSession
remoteAddress
in interface INioSession
public INioSession.Status status()
INioSession
status
in interface INioSession
public void status(INioSession.Status status)
INioSession
status
in interface INioSession
status
- 会话状态对象public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
public void closeNow() throws IOException
INioSession
closeNow
in interface INioSession
IOException
- 可能产生的I/O异常public void registerEvent(int ops) throws IOException
INioSession
registerEvent
in interface INioSession
ops
- 事件参数IOException
- 可能产生的异常public void selectionKey(SelectionKey key)
INioSession
selectionKey
in interface INioSession
key
- 选择键public SelectionKey selectionKey()
INioSession
selectionKey
in interface INioSession
public boolean connectSync(long time)
INioSession
connectSync
in interface INioSession
time
- 等待时间(毫秒)public void finishConnect()
INioSession
finishConnect
in interface INioSession
protected void bufferReset(ByteBufferBuilder buffer)
protected void postMessageReceived(Object message)
public void read() throws IOException
INioSession
read
in interface INioSession
IOException
- 可能产生的I/O异常public void write() throws IOException
INioSession
write
in interface INioSession
IOException
- 可能产生的I/O异常public void send(Object message)
INioSession
send
in interface INioSession
message
- 消息对象Copyright © 2022. All rights reserved.