|
@@ -1,13 +1,17 @@
|
|
|
package com.nb.web.service.bus.websocket.topic;
|
|
package com.nb.web.service.bus.websocket.topic;
|
|
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
|
+import com.nb.auth.bean.LoginUser;
|
|
|
import com.nb.web.service.bus.hospital.his.HisScriptSessionManager;
|
|
import com.nb.web.service.bus.hospital.his.HisScriptSessionManager;
|
|
|
import com.nb.core.Constants;
|
|
import com.nb.core.Constants;
|
|
|
import com.nb.common.websocket.handler.Subscribe;
|
|
import com.nb.common.websocket.handler.Subscribe;
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.tio.core.ChannelContext;
|
|
import org.tio.core.ChannelContext;
|
|
|
|
|
|
|
|
|
|
+import static com.nb.core.Constants.LOGIN_USER_KEY;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* @author lifang
|
|
* @author lifang
|
|
|
* @version 1.0.0
|
|
* @version 1.0.0
|
|
@@ -16,6 +20,7 @@ import org.tio.core.ChannelContext;
|
|
|
* @createTime 2022年03月25日 17:07:00
|
|
* @createTime 2022年03月25日 17:07:00
|
|
|
*/
|
|
*/
|
|
|
@Component
|
|
@Component
|
|
|
|
|
+@Slf4j
|
|
|
public class WebSocketCloseHandler extends Subscribe {
|
|
public class WebSocketCloseHandler extends Subscribe {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private HisScriptSessionManager scriptSessionManager;
|
|
private HisScriptSessionManager scriptSessionManager;
|
|
@@ -26,6 +31,12 @@ public class WebSocketCloseHandler extends Subscribe {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public void close(ChannelContext channelContext) {
|
|
public void close(ChannelContext channelContext) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ LoginUser loginUser = (LoginUser) channelContext.getAttribute(LOGIN_USER_KEY);
|
|
|
|
|
+ log.error("ws因断开连接 操作系统:{},username: {}",loginUser.getOs(),loginUser.getUsername());
|
|
|
|
|
+ }catch (Exception e){
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
Object hospitalId=channelContext.get(Constants.HOSPITAL_ID);
|
|
Object hospitalId=channelContext.get(Constants.HOSPITAL_ID);
|
|
|
if (ObjectUtil.isNotNull(hospitalId)) {
|
|
if (ObjectUtil.isNotNull(hospitalId)) {
|
|
|
scriptSessionManager.get(String.valueOf(hospitalId)).offline();;
|
|
scriptSessionManager.get(String.valueOf(hospitalId)).offline();;
|