public class WebSocketManager extends Object
| 构造器和说明 |
|---|
WebSocketManager() |
| 限定符和类型 | 方法和说明 |
|---|---|
static void |
add(Long userId,
javax.websocket.Session session)
添加用户ID相关的Session
|
static List<javax.websocket.Session> |
getSessionByUserId(Long userId)
根据用户ID获取Session
|
static Set<Long> |
getUserList()
获取链接用户集合
|
static void |
removeSession(Long userId,
javax.websocket.Session session)
移除失效的Session
|
static void |
sendMessage(Long userId,
String message)
发送消息
|
static void |
sendMessageToAll(String message)
发送消息
|
public static void add(Long userId, javax.websocket.Session session)
userId - 用户idsession - 用户websocketSessionpublic static List<javax.websocket.Session> getSessionByUserId(Long userId)
userId - 用户idpublic static void removeSession(Long userId, javax.websocket.Session session)
userId - 用户idsession - 用户websocketSessionpublic static void sendMessage(Long userId, String message)
userId - 用户idmessage - 消息public static void sendMessageToAll(String message)
message - 消息Copyright © 2021. All rights reserved.