public class WebSocketHandler
extends org.springframework.web.socket.handler.TextWebSocketHandler
建立连接 断开连接 收到消息
| 构造器和说明 |
|---|
WebSocketHandler(EventProperties eventProperties,
CoolQFactory coolQFactory,
ApiHandler apiHandler,
EventHandler eventHandler) |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
afterConnectionClosed(org.springframework.web.socket.WebSocketSession session,
org.springframework.web.socket.CloseStatus status)
ws连接断开,需要清除之前的CoolQ对象
|
void |
afterConnectionEstablished(org.springframework.web.socket.WebSocketSession session)
ws建立连接,创建CoolQ对象,并放入CQGlobal.robots,是static Map,方便在jar外面获取
|
protected void |
handleTextMessage(org.springframework.web.socket.WebSocketSession session,
org.springframework.web.socket.TextMessage message)
ws收到消息时的方法
可能是api响应(包含echo字段)
可能是事件上报
|
public WebSocketHandler(EventProperties eventProperties, CoolQFactory coolQFactory, ApiHandler apiHandler, EventHandler eventHandler)
public void afterConnectionEstablished(org.springframework.web.socket.WebSocketSession session)
afterConnectionEstablished 在接口中 org.springframework.web.socket.WebSocketHandlerafterConnectionEstablished 在类中 org.springframework.web.socket.handler.AbstractWebSocketHandlersession - websocket sessionpublic void afterConnectionClosed(org.springframework.web.socket.WebSocketSession session,
org.springframework.web.socket.CloseStatus status)
afterConnectionClosed 在接口中 org.springframework.web.socket.WebSocketHandlerafterConnectionClosed 在类中 org.springframework.web.socket.handler.AbstractWebSocketHandlersession - websocket sessionstatus - 状态码protected void handleTextMessage(org.springframework.web.socket.WebSocketSession session,
org.springframework.web.socket.TextMessage message)
handleTextMessage 在类中 org.springframework.web.socket.handler.AbstractWebSocketHandlersession - websocketSessionmessage - 消息内容Copyright © 2020. All rights reserved.