LISTENER
- 监听器类型public abstract class AbstractNioClient<LISTENER extends IListener<INioSession>> extends Object implements IClient<LISTENER,INioCodec>
Constructor and Description |
---|
AbstractNioClient() |
Modifier and Type | Method and Description |
---|---|
protected abstract INioEventGroup<LISTENER> |
buildEventGroup(IClientCfg clientCfg,
LISTENER listener,
INioCodec codec)
由子类实现创建多路复用通道事件处理器逻辑
|
IClientCfg |
clientCfg()
获取客户端配置对象
|
void |
close() |
void |
connect()
连接远程服务端
|
void |
initialize(IClientCfg clientCfg,
LISTENER listener,
INioCodec codec,
IReconnectService reconnectService,
IHeartbeatService<?> heartbeatService)
初始化客户端服务
|
boolean |
isClosing()
是否正在关闭
|
boolean |
isConnected()
是否已连接
|
long |
lastTouchTime()
获取最后更新会话状态的时间(毫秒)
|
<T extends LISTENER> |
listener()
获取监听器
|
void |
reconnect()
重连远程服务端
|
void |
send(Object message)
向远程服务发送消息
|
void |
touch()
更新会话活动状态
|
protected abstract INioEventGroup<LISTENER> buildEventGroup(IClientCfg clientCfg, LISTENER listener, INioCodec codec) throws IOException
clientCfg
- 客户端配置对象listener
- 事件监听器codec
- 编解码器IOException
- 可能产生的I/O异常public void initialize(IClientCfg clientCfg, LISTENER listener, INioCodec codec, IReconnectService reconnectService, IHeartbeatService<?> heartbeatService)
IClient
initialize
in interface IClient<LISTENER extends IListener<INioSession>,INioCodec>
clientCfg
- 客户端配置listener
- 事件适配器codec
- 解码器reconnectService
- 断线重连服务heartbeatService
- 链路维护(心跳)服务public void connect() throws IOException
IClient
connect
in interface IClient<LISTENER extends IListener<INioSession>,INioCodec>
IOException
- 可能产生的异常public void reconnect() throws IOException
IClient
reconnect
in interface IClient<LISTENER extends IListener<INioSession>,INioCodec>
IOException
- 可能产生的异常public boolean isConnected()
IClient
isConnected
in interface IClient<LISTENER extends IListener<INioSession>,INioCodec>
public boolean isClosing()
IClient
public IClientCfg clientCfg()
IClient
public void send(Object message) throws IOException
IClient
send
in interface IClient<LISTENER extends IListener<INioSession>,INioCodec>
message
- 消息对象IOException
- 可能产生的异常public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
public void touch()
IClient
public long lastTouchTime()
IClient
lastTouchTime
in interface IClient<LISTENER extends IListener<INioSession>,INioCodec>
Copyright © 2022. All rights reserved.