public class SpringWebSocketHandler
extends org.springframework.web.socket.handler.TextWebSocketHandler
| Constructor and Description |
|---|
SpringWebSocketHandler() |
| Modifier and Type | Method and Description |
|---|---|
void |
afterConnectionClosed(org.springframework.web.socket.WebSocketSession websocketSession,
org.springframework.web.socket.CloseStatus closeStatus)
关闭连接时触发,web页面整体刷新,session销毁,浏览器关闭都会触发此方法
|
void |
afterConnectionEstablished(org.springframework.web.socket.WebSocketSession websocketSession)
连接成功时候,会触发页面上onopen方法
|
void |
handleTransportError(org.springframework.web.socket.WebSocketSession websocketSession,
java.lang.Throwable exception) |
void |
sendMessageToUser(java.lang.String userName,
org.springframework.web.socket.TextMessage message)
给某个用户发送消息
|
void |
sendMessageToUsers(org.springframework.web.socket.TextMessage message)
给所有在线用户发送消息
|
boolean |
supportsPartialMessages() |
public void afterConnectionEstablished(org.springframework.web.socket.WebSocketSession websocketSession)
throws java.lang.Exception
afterConnectionEstablished in interface org.springframework.web.socket.WebSocketHandlerafterConnectionEstablished in class org.springframework.web.socket.handler.AbstractWebSocketHandlerjava.lang.Exceptionpublic void afterConnectionClosed(org.springframework.web.socket.WebSocketSession websocketSession,
org.springframework.web.socket.CloseStatus closeStatus)
throws java.lang.Exception
afterConnectionClosed in interface org.springframework.web.socket.WebSocketHandlerafterConnectionClosed in class org.springframework.web.socket.handler.AbstractWebSocketHandlerjava.lang.Exceptionpublic void handleTransportError(org.springframework.web.socket.WebSocketSession websocketSession,
java.lang.Throwable exception)
throws java.lang.Exception
handleTransportError in interface org.springframework.web.socket.WebSocketHandlerhandleTransportError in class org.springframework.web.socket.handler.AbstractWebSocketHandlerjava.lang.Exceptionpublic boolean supportsPartialMessages()
supportsPartialMessages in interface org.springframework.web.socket.WebSocketHandlersupportsPartialMessages in class org.springframework.web.socket.handler.AbstractWebSocketHandlerpublic void sendMessageToUser(java.lang.String userName,
org.springframework.web.socket.TextMessage message)
userName - message - public void sendMessageToUsers(org.springframework.web.socket.TextMessage message)
message -