Package br.com.anteros.mqtt.core.server
Class MqttServerAioHandler
- java.lang.Object
-
- br.com.anteros.mqtt.core.server.MqttServerAioHandler
-
- All Implemented Interfaces:
org.tio.core.intf.AioHandler,org.tio.server.intf.ServerAioHandler
public class MqttServerAioHandler extends Object implements org.tio.server.intf.ServerAioHandler
- Author:
- L.cm
-
-
Constructor Summary
Constructors Constructor Description MqttServerAioHandler(MqttServerCreator serverCreator, MqttServerProcessor processor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.tio.core.intf.Packetdecode(ByteBuffer buffer, int limit, int position, int readableLength, org.tio.core.ChannelContext context)根据ByteBuffer解码成业务需要的Packet对象.ByteBufferencode(org.tio.core.intf.Packet packet, org.tio.core.TioConfig tioConfig, org.tio.core.ChannelContext context)编码voidhandler(org.tio.core.intf.Packet packet, org.tio.core.ChannelContext context)处理消息包
-
-
-
Constructor Detail
-
MqttServerAioHandler
public MqttServerAioHandler(MqttServerCreator serverCreator, MqttServerProcessor processor)
-
-
Method Detail
-
decode
public org.tio.core.intf.Packet decode(ByteBuffer buffer, int limit, int position, int readableLength, org.tio.core.ChannelContext context) throws org.tio.core.exception.TioDecodeException
根据ByteBuffer解码成业务需要的Packet对象. 如果收到的数据不全,导致解码失败,请返回null,在下次消息来时框架层会自动续上前面的收到的数据- Specified by:
decodein interfaceorg.tio.core.intf.AioHandler- Parameters:
buffer- 参与本次希望解码的ByteBufferlimit- ByteBuffer的limitposition- ByteBuffer的position,不一定是0哦readableLength- ByteBuffer参与本次解码的有效数据(= limit - position)context- ChannelContext- Returns:
- Packet
- Throws:
org.tio.core.exception.TioDecodeException
-
encode
public ByteBuffer encode(org.tio.core.intf.Packet packet, org.tio.core.TioConfig tioConfig, org.tio.core.ChannelContext context)
编码- Specified by:
encodein interfaceorg.tio.core.intf.AioHandler- Parameters:
packet- PackettioConfig- TioConfigcontext- ChannelContext- Returns:
- ByteBuffer
-
handler
public void handler(org.tio.core.intf.Packet packet, org.tio.core.ChannelContext context)处理消息包- Specified by:
handlerin interfaceorg.tio.core.intf.AioHandler- Parameters:
packet- Packetcontext- ChannelContext
-
-