|
|
@@ -21,8 +21,6 @@ import com.corundumstudio.socketio.annotation.OnEvent;
|
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import me.zhengjie.security.service.OnlineUserService;
|
|
|
-import me.zhengjie.utils.SpringContextHolder;
|
|
|
-
|
|
|
/**
|
|
|
* @author litong
|
|
|
* @date 2019/11/6 15:59
|
|
|
@@ -52,7 +50,6 @@ public class SocketEventListenner {
|
|
|
if (StringUtils.isNotBlank(pcSname)) {
|
|
|
client.sendEvent("connectSucc", "success");
|
|
|
System.out.println("pc建立连接");
|
|
|
-
|
|
|
}
|
|
|
String appSname = handshakeData.getSingleUrlParam("appSname");
|
|
|
if (StringUtils.isNotBlank(appSname)) {
|
|
|
@@ -115,7 +112,19 @@ public class SocketEventListenner {
|
|
|
param.put("pcSname", list);
|
|
|
UUID sessionId = client.getSessionId();
|
|
|
// 移除用户
|
|
|
- pcSocketClientCache.deleteSname(pcSname);
|
|
|
+ HashMap<UUID, SocketIOClient> socketIOClient = pcSocketClientCache.getUserClient(pcSname);
|
|
|
+ if (socketIOClient != null) {
|
|
|
+ Collection<SocketIOClient> collection = socketIOClient.values();
|
|
|
+ for (SocketIOClient ioClient : collection) {
|
|
|
+ log.info("发送退出登录:" + pcSname);
|
|
|
+ ioClient.sendEvent("logoutEvent", "close");
|
|
|
+ }
|
|
|
+ for (SocketIOClient ioClient : collection) {
|
|
|
+ ioClient.disconnect();
|
|
|
+ }
|
|
|
+ pcSocketClientCache.deleteSname(pcSname);
|
|
|
+ }
|
|
|
+
|
|
|
pcSocketClientCache.saveClient(pcSname, sessionId, client);
|
|
|
log.info("将sname注册到websocket里面:" + pcSname);
|
|
|
} else {
|
|
|
@@ -126,7 +135,10 @@ public class SocketEventListenner {
|
|
|
for (SocketIOClient ioClient : collection) {
|
|
|
ioClient.sendEvent("logoutEvent", "close");
|
|
|
}
|
|
|
- client.disconnect();
|
|
|
+ for (SocketIOClient ioClient : collection) {
|
|
|
+ ioClient.disconnect();
|
|
|
+ }
|
|
|
+ pcSocketClientCache.deleteSname(pcSname);
|
|
|
}
|
|
|
}
|
|
|
}
|