|  | @@ -5,6 +5,8 @@ import com.ym.mec.auth.api.entity.SysUser;
 | 
	
		
			
				|  |  |  import org.slf4j.Logger;
 | 
	
		
			
				|  |  |  import org.slf4j.LoggerFactory;
 | 
	
		
			
				|  |  |  import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  | +import org.springframework.security.core.Authentication;
 | 
	
		
			
				|  |  | +import org.springframework.security.core.context.SecurityContextHolder;
 | 
	
		
			
				|  |  |  import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  |  import org.springframework.web.socket.*;
 | 
	
		
			
				|  |  |  import org.springframework.web.socket.handler.AbstractWebSocketHandler;
 | 
	
	
		
			
				|  | @@ -23,6 +25,7 @@ public class WebSocketHandler extends AbstractWebSocketHandler {
 | 
	
		
			
				|  |  |      private static final Logger LOGGER = LoggerFactory.getLogger(WebSocketHandler.class);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      private final Map<String, WebSocketSession> clients = new ConcurrentHashMap<>();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private SysUserFeignService sysUserFeignService;
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -32,20 +35,18 @@ public class WebSocketHandler extends AbstractWebSocketHandler {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public void afterConnectionEstablished(WebSocketSession session) throws Exception {
 | 
	
		
			
				|  |  | +        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
 | 
	
		
			
				|  |  |          SysUser sysUser = sysUserFeignService.queryUserInfo();
 | 
	
		
			
				|  |  |          if(Objects.isNull(sysUser)){
 | 
	
		
			
				|  |  |              LOGGER.error("用户登录信息异常");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        LOGGER.info("有新的客户端上线: {}", sysUser.getRealName());
 | 
	
		
			
				|  |  | +        LOGGER.info("有新的客户端上线: {}", authentication.getPrincipal());
 | 
	
		
			
				|  |  |          super.afterConnectionEstablished(session);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public void handleMessage(WebSocketSession session, WebSocketMessage<?> message) throws Exception {SysUser sysUser = sysUserFeignService.queryUserInfo();
 | 
	
		
			
				|  |  | -        if(Objects.isNull(sysUser)){
 | 
	
		
			
				|  |  | -            LOGGER.error("用户登录信息异常");
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        LOGGER.info("{}: {}", sysUser.getRealName(), message);
 | 
	
		
			
				|  |  | +        LOGGER.info("{}: {}", SecurityContextHolder.getContext().getAuthentication().getPrincipal(), message);
 | 
	
		
			
				|  |  |          super.handleMessage(session, message);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -75,11 +76,7 @@ public class WebSocketHandler extends AbstractWebSocketHandler {
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public void afterConnectionClosed(WebSocketSession session, CloseStatus status) throws Exception {
 | 
	
		
			
				|  |  |          super.afterConnectionClosed(session, status);
 | 
	
		
			
				|  |  | -        SysUser sysUser = sysUserFeignService.queryUserInfo();
 | 
	
		
			
				|  |  | -        if(Objects.isNull(sysUser)){
 | 
	
		
			
				|  |  | -            LOGGER.error("用户登录信息异常");
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        LOGGER.info("{}离线", sysUser.getRealName());
 | 
	
		
			
				|  |  | +        LOGGER.info("{}离线", SecurityContextHolder.getContext().getAuthentication().getPrincipal());
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 |