public class DefaultAioListener extends Object implements ClientAioListener, ServerAioListener
Constructor and Description |
---|
DefaultAioListener() |
Modifier and Type | Method and Description |
---|---|
void |
onAfterConnected(ChannelContext channelContext,
boolean isConnected,
boolean isReconnect)
建链后触发本方法,注:建链不一定成功,需要关注参数isConnected
|
void |
onAfterDecoded(ChannelContext channelContext,
Packet packet,
int packetSize)
原方法名:onAfterDecoded
解码成功后触发本方法
|
void |
onAfterHandled(ChannelContext channelContext,
Packet packet,
long cost)
处理一个消息包后
|
void |
onAfterReceivedBytes(ChannelContext channelContext,
int receivedBytes)
接收到TCP层传过来的数据后
|
void |
onAfterSent(ChannelContext channelContext,
Packet packet,
boolean isSentSuccess)
消息包发送之后触发本方法
|
void |
onBeforeClose(ChannelContext channelContext,
Throwable throwable,
String remark,
boolean isRemove)
连接关闭前触发本方法
|
boolean |
onHeartbeatTimeout(ChannelContext channelContext,
Long interval,
int heartbeatTimeoutCount)
服务器检查到心跳超时时,会调用这个函数(一般场景,该方法只需要直接返回false即可)
|
public void onAfterConnected(ChannelContext channelContext, boolean isConnected, boolean isReconnect)
AioListener
onAfterConnected
in interface AioListener
channelContext
- isConnected
- isReconnect
- public void onAfterDecoded(ChannelContext channelContext, Packet packet, int packetSize)
AioListener
onAfterDecoded
in interface AioListener
channelContext
- packet
- packetSize
- public void onAfterSent(ChannelContext channelContext, Packet packet, boolean isSentSuccess) throws Exception
AioListener
onAfterSent
in interface AioListener
channelContext
- packet
- isSentSuccess
- Exception
public void onBeforeClose(ChannelContext channelContext, Throwable throwable, String remark, boolean isRemove)
AioListener
onBeforeClose
in interface AioListener
channelContext
- the channelcontextthrowable
- the throwable 有可能为空remark
- the remark 有可能为空public void onAfterHandled(ChannelContext channelContext, Packet packet, long cost) throws Exception
AioListener
onAfterHandled
in interface AioListener
cost
- 本次处理消息耗时,单位:毫秒Exception
public void onAfterReceivedBytes(ChannelContext channelContext, int receivedBytes) throws Exception
AioListener
onAfterReceivedBytes
in interface AioListener
receivedBytes
- 本次接收了多少字节Exception
public boolean onHeartbeatTimeout(ChannelContext channelContext, Long interval, int heartbeatTimeoutCount)
ServerAioListener
onHeartbeatTimeout
in interface ServerAioListener
interval
- 已经多久没有收发消息了,单位:毫秒heartbeatTimeoutCount
- 心跳超时次数,第一次超时此值是1,以此类推。此值被保存在:channelContext.stat.heartbeatTimeoutCountCopyright © 2021. All rights reserved.