类 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
-
字段概要
字段 -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明final voidafterConnectionClosed(@NotNull org.springframework.web.socket.WebSocketSession session, @NotNull org.springframework.web.socket.CloseStatus status) final voidafterConnectionEstablished(org.springframework.web.socket.WebSocketSession session) 连接就绪后监听队列protected final org.eclipse.paho.client.mqttv3.MqttClientgetMqttClient(@NotNull org.springframework.web.socket.WebSocketSession session) 获取MQTT客户端protected final @NotNull StringgetRealChannel(String channel) 获取真实的频道protected final org.springframework.data.redis.connection.SubscriptiongetRedisSubscription(@NotNull org.springframework.web.socket.WebSocketSession session) 获取Redis订阅protected final voidhandleTextMessage(org.springframework.web.socket.WebSocketSession session, @NotNull org.springframework.web.socket.TextMessage textMessage) 收到Websocket消息时protected final voidmqttSubscribe(String channel, org.springframework.web.socket.WebSocketSession session) MQTT订阅protected final voidmqttUnSubscribe(String channel, org.springframework.web.socket.WebSocketSession session) MQTT订阅final voidonMessage(@NotNull org.springframework.data.redis.connection.Message message, byte[] pattern) voidonWebSocketPayload(@NotNull WebSocketPayload webSocketPayload, @NotNull org.springframework.web.socket.WebSocketSession session) 当WebSocket负载到达时protected final voidredisSubscribe(@NotNull String channel, org.springframework.web.socket.WebSocketSession session) REDIS订阅protected final voidredisUnSubscribe(@NotNull String channel, org.springframework.web.socket.WebSocketSession session) Redis订阅protected final voidsendWebSocketPayload(@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
-
字段详细资料
-
构造器详细资料
-
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
获取真实的频道
- 参数:
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订阅
-