Package api.log.socket
Class SocketHandler
java.lang.Object
org.springframework.web.socket.handler.AbstractWebSocketHandler
org.springframework.web.socket.handler.TextWebSocketHandler
api.log.socket.SocketHandler
- All Implemented Interfaces:
org.springframework.web.socket.WebSocketHandler
@Component("alogSocketHandler")
public class SocketHandler
extends org.springframework.web.socket.handler.TextWebSocketHandler
WebSocket处理器
- Author:
- chenenwei
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidafterConnectionClosed(org.springframework.web.socket.WebSocketSession session, org.springframework.web.socket.CloseStatus status) 连接关闭voidafterConnectionEstablished(org.springframework.web.socket.WebSocketSession session) 连接建立protected voidhandleTextMessage(org.springframework.web.socket.WebSocketSession session, org.springframework.web.socket.TextMessage message) 处理消息voidsendToClient(org.springframework.web.socket.WebSocketSession session, String message) 发送消息到客户端Methods inherited from class org.springframework.web.socket.handler.TextWebSocketHandler
handleBinaryMessageMethods inherited from class org.springframework.web.socket.handler.AbstractWebSocketHandler
handleMessage, handlePongMessage, handleTransportError, supportsPartialMessages
-
Constructor Details
-
SocketHandler
public SocketHandler()构造方法
-
-
Method Details
-
afterConnectionEstablished
public void afterConnectionEstablished(org.springframework.web.socket.WebSocketSession session) 连接建立- Specified by:
afterConnectionEstablishedin interfaceorg.springframework.web.socket.WebSocketHandler- Overrides:
afterConnectionEstablishedin classorg.springframework.web.socket.handler.AbstractWebSocketHandler- Parameters:
session- session
-
afterConnectionClosed
public void afterConnectionClosed(org.springframework.web.socket.WebSocketSession session, org.springframework.web.socket.CloseStatus status) throws Exception 连接关闭- Specified by:
afterConnectionClosedin interfaceorg.springframework.web.socket.WebSocketHandler- Overrides:
afterConnectionClosedin classorg.springframework.web.socket.handler.AbstractWebSocketHandler- Parameters:
session- sessionstatus- 状态- Throws:
Exception- 异常
-
handleTextMessage
protected void handleTextMessage(org.springframework.web.socket.WebSocketSession session, org.springframework.web.socket.TextMessage message) throws Exception 处理消息- Overrides:
handleTextMessagein classorg.springframework.web.socket.handler.AbstractWebSocketHandler- Parameters:
session- sessionmessage- 消息- Throws:
Exception- 异常
-
sendToClient
发送消息到客户端- Parameters:
session- sessionmessage- 消息
-