Class MqttWsMsgHandler

  • All Implemented Interfaces:
    org.tio.websocket.server.handler.IWsMsgHandler, org.tio.websocket.server.handler.IWsSubProtocolsMsgHandler

    public class MqttWsMsgHandler
    extends Object
    implements org.tio.websocket.server.handler.IWsMsgHandler
    mqtt websocket 消息处理
    Author:
    L.cm
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.tio.websocket.common.WsResponse encodeSubProtocol​(org.tio.core.intf.Packet packet, org.tio.core.TioConfig tioConfig, org.tio.core.ChannelContext context)  
      String[] getSupportedSubProtocols()  
      org.tio.http.common.HttpResponse handshake​(org.tio.http.common.HttpRequest request, org.tio.http.common.HttpResponse httpResponse, org.tio.core.ChannelContext channelContext)  
      void onAfterHandshaked​(org.tio.http.common.HttpRequest request, org.tio.http.common.HttpResponse response, org.tio.core.ChannelContext context)
      握手后处理
      Object onBytes​(org.tio.websocket.common.WsRequest wsRequest, byte[] bytes, org.tio.core.ChannelContext context)
      字节消息(binaryType = arraybuffer)过来后会走这个方法
      Object onClose​(org.tio.websocket.common.WsRequest wsRequest, byte[] bytes, org.tio.core.ChannelContext context)
      当客户端发 close flag 时,会走这个方法
      Object onText​(org.tio.websocket.common.WsRequest wsRequest, String text, org.tio.core.ChannelContext context)
      字符消息(binaryType = blob)过来后会走这个方法
    • Constructor Detail

      • MqttWsMsgHandler

        public MqttWsMsgHandler​(MqttServerCreator serverCreator,
                                org.tio.core.intf.AioHandler aioHandler)
      • MqttWsMsgHandler

        public MqttWsMsgHandler​(MqttServerCreator serverCreator,
                                String[] supportedSubProtocols,
                                org.tio.core.intf.AioHandler aioHandler)
    • Method Detail

      • getSupportedSubProtocols

        public String[] getSupportedSubProtocols()
        Specified by:
        getSupportedSubProtocols in interface org.tio.websocket.server.handler.IWsSubProtocolsMsgHandler
      • handshake

        public org.tio.http.common.HttpResponse handshake​(org.tio.http.common.HttpRequest request,
                                                          org.tio.http.common.HttpResponse httpResponse,
                                                          org.tio.core.ChannelContext channelContext)
        Specified by:
        handshake in interface org.tio.websocket.server.handler.IWsMsgHandler
      • onAfterHandshaked

        public void onAfterHandshaked​(org.tio.http.common.HttpRequest request,
                                      org.tio.http.common.HttpResponse response,
                                      org.tio.core.ChannelContext context)
        握手后处理
        Specified by:
        onAfterHandshaked in interface org.tio.websocket.server.handler.IWsMsgHandler
        Parameters:
        request - HttpRequest
        response - HttpResponse
        context - ChannelContext
      • onBytes

        public Object onBytes​(org.tio.websocket.common.WsRequest wsRequest,
                              byte[] bytes,
                              org.tio.core.ChannelContext context)
                       throws Exception
        字节消息(binaryType = arraybuffer)过来后会走这个方法
        Specified by:
        onBytes in interface org.tio.websocket.server.handler.IWsMsgHandler
        Throws:
        Exception
      • encodeSubProtocol

        public org.tio.websocket.common.WsResponse encodeSubProtocol​(org.tio.core.intf.Packet packet,
                                                                     org.tio.core.TioConfig tioConfig,
                                                                     org.tio.core.ChannelContext context)
        Specified by:
        encodeSubProtocol in interface org.tio.websocket.server.handler.IWsSubProtocolsMsgHandler
      • onClose

        public Object onClose​(org.tio.websocket.common.WsRequest wsRequest,
                              byte[] bytes,
                              org.tio.core.ChannelContext context)
        当客户端发 close flag 时,会走这个方法
        Specified by:
        onClose in interface org.tio.websocket.server.handler.IWsMsgHandler
      • onText

        public Object onText​(org.tio.websocket.common.WsRequest wsRequest,
                             String text,
                             org.tio.core.ChannelContext context)
        字符消息(binaryType = blob)过来后会走这个方法
        Specified by:
        onText in interface org.tio.websocket.server.handler.IWsMsgHandler