public class WebsocketSendService
extends bap.core.service.BaseService
| Constructor and Description |
|---|
WebsocketSendService() |
| Modifier and Type | Method and Description |
|---|---|
void |
afterConnectionClosed(org.springframework.web.socket.WebSocketSession websocketSession,
org.springframework.web.socket.CloseStatus closeStatus)
websocket会话关闭触发
|
void |
handleTextMessage(org.springframework.web.socket.WebSocketSession websocketSession,
org.springframework.web.socket.TextMessage message)
当前端js发起websocket请求,通过send方法向服务端发送消息时,触发此方法
|
SpringWebSocketHandler |
infoHandler() |
void |
onOpen(org.springframework.web.socket.WebSocketSession websocketSession,
java.lang.String loginName)
websocket客户端打开后,触发此方法
|
void |
sendMessageToUser(java.lang.String loginName,
org.springframework.web.socket.TextMessage msg)
发送消息给指定在线用户
|
void |
sendMessageToUsers(org.springframework.web.socket.TextMessage msg)
发送消息给所有在线用户
|
@Bean public SpringWebSocketHandler infoHandler()
public void sendMessageToUsers(org.springframework.web.socket.TextMessage msg)
msg - 消息public void sendMessageToUser(java.lang.String loginName,
org.springframework.web.socket.TextMessage msg)
loginName - 登录名msg - 消息public void handleTextMessage(org.springframework.web.socket.WebSocketSession websocketSession,
org.springframework.web.socket.TextMessage message)
websocketSession - websokcet会话message - 客户端向服务端发送的消息public void onOpen(org.springframework.web.socket.WebSocketSession websocketSession,
java.lang.String loginName)
websocketSession - websocket会话loginName - 客户端用户的登录名public void afterConnectionClosed(org.springframework.web.socket.WebSocketSession websocketSession,
org.springframework.web.socket.CloseStatus closeStatus)
websocketSession - websocket会话closeStatus - 关闭状态