public class HelloClientAioHandler extends Object implements org.tio.core.intf.AioHandler, org.tio.client.intf.ClientAioHandler
| Constructor and Description |
|---|
HelloClientAioHandler() |
| Modifier and Type | Method and Description |
|---|---|
TcpPacket |
decode(ByteBuffer buffer,
int limit,
int position,
int readableLength,
org.tio.core.ChannelContext channelContext) |
ByteBuffer |
encode(org.tio.core.intf.Packet packet,
org.tio.core.GroupContext groupContext,
org.tio.core.ChannelContext channelContext)
编码:把业务消息包编码为可以发送的ByteBuffer
总的消息结构:消息头 + 消息体
消息头结构: 4个字节,存储消息体的长度
消息体结构: 对象的json串的byte[]
|
void |
handler(org.tio.core.intf.Packet packet,
org.tio.core.ChannelContext channelContext)
处理消息
|
TcpPacket |
heartbeatPacket()
此方法如果返回null,框架层面则不会发心跳;如果返回非null,框架层面会定时发本方法返回的消息包
|
public void handler(org.tio.core.intf.Packet packet,
org.tio.core.ChannelContext channelContext)
throws Exception
handler in interface org.tio.core.intf.AioHandlerExceptionpublic ByteBuffer encode(org.tio.core.intf.Packet packet, org.tio.core.GroupContext groupContext, org.tio.core.ChannelContext channelContext)
encode in interface org.tio.core.intf.AioHandlerpublic TcpPacket decode(ByteBuffer buffer, int limit, int position, int readableLength, org.tio.core.ChannelContext channelContext) throws org.tio.core.exception.AioDecodeException
decode in interface org.tio.core.intf.AioHandlerorg.tio.core.exception.AioDecodeExceptionpublic TcpPacket heartbeatPacket()
heartbeatPacket in interface org.tio.client.intf.ClientAioHandlerCopyright © 2018. All rights reserved.