Class 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
    • 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:
        decode in interface org.tio.core.intf.AioHandler
        Parameters:
        buffer - 参与本次希望解码的ByteBuffer
        limit - ByteBuffer的limit
        position - 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:
        encode in interface org.tio.core.intf.AioHandler
        Parameters:
        packet - Packet
        tioConfig - TioConfig
        context - ChannelContext
        Returns:
        ByteBuffer
      • handler

        public void handler​(org.tio.core.intf.Packet packet,
                            org.tio.core.ChannelContext context)
        处理消息包
        Specified by:
        handler in interface org.tio.core.intf.AioHandler
        Parameters:
        packet - Packet
        context - ChannelContext