bugfix 修复开启多个门禁websocket频繁断开问题;bugfix仅扫描门禁显示提示窗
This commit is contained in:
@@ -18,7 +18,7 @@ public class WebSocketServer {
|
||||
private Session session;
|
||||
|
||||
// session集合,存放对应的session
|
||||
private static ConcurrentHashMap<Integer, Session> sessionPool = new ConcurrentHashMap<>();
|
||||
private static ConcurrentHashMap<String, Session> sessionPool = new ConcurrentHashMap<>();
|
||||
|
||||
// concurrent包的线程安全Set,用来存放每个客户端对应的WebSocket对象。
|
||||
private static CopyOnWriteArraySet<WebSocketServer> webSocketSet = new CopyOnWriteArraySet<>();
|
||||
@@ -30,7 +30,7 @@ public class WebSocketServer {
|
||||
* @param userId 用户ID
|
||||
*/
|
||||
@OnOpen
|
||||
public void onOpen(Session session, @PathParam(value = "userId") Integer userId) {
|
||||
public void onOpen(Session session, @PathParam(value = "userId") String userId) {
|
||||
log.info("WebSocket建立连接中,连接用户ID:{}", userId);
|
||||
try {
|
||||
Session historySession = sessionPool.get(userId);
|
||||
@@ -84,7 +84,7 @@ public class WebSocketServer {
|
||||
* @param userId 用户ID
|
||||
* @param message 发送的消息
|
||||
*/
|
||||
public static void sendMessageByUser(Integer userId, String message) {
|
||||
public static void sendMessageByUser(String userId, String message) {
|
||||
log.info("用户ID:" + userId + ",推送内容:" + message);
|
||||
Session session = sessionPool.get(userId);
|
||||
try {
|
||||
|
Reference in New Issue
Block a user