类 WebSocketHandler

java.lang.Object
org.springframework.web.socket.handler.AbstractWebSocketHandler
org.springframework.web.socket.handler.TextWebSocketHandler
cn.hamm.airpower.websocket.WebSocketHandler
所有已实现的接口:
org.springframework.data.redis.connection.MessageListener, org.springframework.web.socket.WebSocketHandler

@Component public class WebSocketHandler extends org.springframework.web.socket.handler.TextWebSocketHandler implements org.springframework.data.redis.connection.MessageListener

WebSocket Handler

作者:
Hamm
  • 字段概要

    字段
    修饰符和类型
    字段
    说明
    static final String
    订阅全频道
    static final String
    订阅用户频道前缀
    protected final HashMap<String,org.eclipse.paho.client.mqttv3.MqttClient>
    MQTT客户端Map
    protected final HashMap<String,org.springframework.data.redis.connection.RedisConnection>
    Redis连接Map
    protected final HashMap<String,Long>
    用户IDMap
  • 构造器概要

    构造器
    构造器
    说明
     
  • 方法概要

    修饰符和类型
    方法
    说明
    final void
    afterConnectionClosed(@NotNull org.springframework.web.socket.WebSocketSession session, @NotNull org.springframework.web.socket.CloseStatus status)
     
    final void
    afterConnectionEstablished(org.springframework.web.socket.WebSocketSession session)
    连接就绪后监听队列
    protected final org.eclipse.paho.client.mqttv3.MqttClient
    getMqttClient(@NotNull org.springframework.web.socket.WebSocketSession session)
    获取MQTT客户端
    protected final @NotNull String
    获取真实的频道
    protected final org.springframework.data.redis.connection.Subscription
    getRedisSubscription(@NotNull org.springframework.web.socket.WebSocketSession session)
    获取Redis订阅
    protected final void
    handleTextMessage(org.springframework.web.socket.WebSocketSession session, @NotNull org.springframework.web.socket.TextMessage textMessage)
    收到Websocket消息时
    protected final void
    mqttSubscribe(String channel, org.springframework.web.socket.WebSocketSession session)
    MQTT订阅
    protected final void
    mqttUnSubscribe(String channel, org.springframework.web.socket.WebSocketSession session)
    MQTT订阅
    final void
    onMessage(@NotNull org.springframework.data.redis.connection.Message message, byte[] pattern)
     
    void
    onWebSocketPayload(@NotNull WebSocketPayload webSocketPayload, @NotNull org.springframework.web.socket.WebSocketSession session)
    当WebSocket负载到达时
    protected final void
    redisSubscribe(@NotNull String channel, org.springframework.web.socket.WebSocketSession session)
    REDIS订阅
    protected final void
    redisUnSubscribe(@NotNull String channel, org.springframework.web.socket.WebSocketSession session)
    Redis订阅
    protected final void
    sendWebSocketPayload(@NotNull org.springframework.web.socket.WebSocketSession session, @NotNull WebSocketPayload webSocketPayload)
     

    从类继承的方法 org.springframework.web.socket.handler.TextWebSocketHandler

    handleBinaryMessage

    从类继承的方法 org.springframework.web.socket.handler.AbstractWebSocketHandler

    handleMessage, handlePongMessage, handleTransportError, supportsPartialMessages

    从类继承的方法 java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 字段详细资料

    • CHANNEL_ALL

      public static final String CHANNEL_ALL

      订阅全频道

      另请参阅:
    • CHANNEL_USER_PREFIX

      public static final String CHANNEL_USER_PREFIX

      订阅用户频道前缀

      另请参阅:
    • redisConnectionHashMap

      protected final HashMap<String,org.springframework.data.redis.connection.RedisConnection> redisConnectionHashMap

      Redis连接Map

    • mqttClientHashMap

      protected final HashMap<String,org.eclipse.paho.client.mqttv3.MqttClient> mqttClientHashMap

      MQTT客户端Map

    • userIdHashMap

      protected final HashMap<String,Long> userIdHashMap

      用户IDMap

  • 构造器详细资料

    • WebSocketHandler

      public WebSocketHandler()
  • 方法详细资料

    • handleTextMessage

      protected final void handleTextMessage(@NonNull org.springframework.web.socket.WebSocketSession session, @NotNull @NotNull org.springframework.web.socket.TextMessage textMessage)

      收到Websocket消息时

      覆盖:
      handleTextMessage 在类中 org.springframework.web.socket.handler.AbstractWebSocketHandler
      参数:
      session - 会话
      textMessage - 文本消息
    • sendWebSocketPayload

      protected final void sendWebSocketPayload(@NotNull @NotNull org.springframework.web.socket.WebSocketSession session, @NotNull @NotNull WebSocketPayload webSocketPayload)
    • onWebSocketPayload

      public void onWebSocketPayload(@NotNull @NotNull WebSocketPayload webSocketPayload, @NotNull @NotNull org.springframework.web.socket.WebSocketSession session)

      当WebSocket负载到达时

      参数:
      webSocketPayload - 负载对象
    • afterConnectionEstablished

      public final void afterConnectionEstablished(@NonNull org.springframework.web.socket.WebSocketSession session)

      连接就绪后监听队列

      指定者:
      afterConnectionEstablished 在接口中 org.springframework.web.socket.WebSocketHandler
      覆盖:
      afterConnectionEstablished 在类中 org.springframework.web.socket.handler.AbstractWebSocketHandler
      参数:
      session - 会话
    • afterConnectionClosed

      @Contract(pure=true) public final void afterConnectionClosed(@NotNull @NotNull org.springframework.web.socket.WebSocketSession session, @NotNull @NotNull org.springframework.web.socket.CloseStatus status)
      指定者:
      afterConnectionClosed 在接口中 org.springframework.web.socket.WebSocketHandler
      覆盖:
      afterConnectionClosed 在类中 org.springframework.web.socket.handler.AbstractWebSocketHandler
    • onMessage

      @Contract(pure=true) public final void onMessage(@NotNull @NotNull org.springframework.data.redis.connection.Message message, byte[] pattern)
      指定者:
      onMessage 在接口中 org.springframework.data.redis.connection.MessageListener
    • redisSubscribe

      protected final void redisSubscribe(@NotNull @NotNull String channel, org.springframework.web.socket.WebSocketSession session)

      REDIS订阅

      参数:
      channel - 传入的频道
      session - WebSocket会话
    • mqttSubscribe

      protected final void mqttSubscribe(String channel, org.springframework.web.socket.WebSocketSession session)

      MQTT订阅

      参数:
      channel - 传入的频道
      session - WebSocket会话
    • getRealChannel

      @NotNull protected final @NotNull String getRealChannel(String channel)

      获取真实的频道

      参数:
      channel - 传入的频道
      返回:
      带前缀的真实频道
    • redisUnSubscribe

      protected final void redisUnSubscribe(@NotNull @NotNull String channel, org.springframework.web.socket.WebSocketSession session)

      Redis订阅

      参数:
      channel - 传入的频道
      session - WebSocket会话
    • mqttUnSubscribe

      protected final void mqttUnSubscribe(String channel, org.springframework.web.socket.WebSocketSession session)

      MQTT订阅

      参数:
      channel - 传入的频道
      session - WebSocket会话
    • getMqttClient

      protected final org.eclipse.paho.client.mqttv3.MqttClient getMqttClient(@NotNull @NotNull org.springframework.web.socket.WebSocketSession session)

      获取MQTT客户端

      参数:
      session - WebSocket会话
      返回:
      MQTT客户端
    • getRedisSubscription

      protected final org.springframework.data.redis.connection.Subscription getRedisSubscription(@NotNull @NotNull org.springframework.web.socket.WebSocketSession session)

      获取Redis订阅

      参数:
      session - WebSocket会话
      返回:
      Redis订阅