Commit 76f19c4a authored by 冯景珉's avatar 冯景珉

Update websocket.md

parent 8dcad5e5
......@@ -49,11 +49,14 @@ function initWebSocket() {
#### 获取SocketSessionMap
1.先注入WebSocketSessionManager类型bean。
2.调用其中的getSession方法,其中包含两个getSession方法:
* getSession(String username) 可以根据username获取对应的webscoketSession集合。
* getSession(String userId)可以根据userId获取对应的websocketSession集合。
3.获取websocketSession对象之后,调用其中的sendMessage方法即可,参数推荐自己构造一个TextMessage类型的对象,其中构造方法参数为String类型。
4.建议在发送消息前进行连接进行状态判断,避免异常,以及及时从集合中移除无用的websocketSession。
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment