| | |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.TypeReference; |
| | | import com.ard.common.core.domain.model.LoginUser; |
| | | import com.ard.framework.web.service.TokenService; |
| | | import com.ard.work.component.websocket.WebSocketSessionManager; |
| | | import com.ard.work.domain.enums.MessageType; |
| | | import com.ard.work.domain.message.*; |
| | |
| | | import org.springframework.web.socket.TextMessage; |
| | | import org.springframework.web.socket.WebSocketSession; |
| | | import org.springframework.web.socket.handler.TextWebSocketHandler; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.concurrent.CompletableFuture; |
| | | |
| | | |
| | | @Component |
| | |
| | | private UavControlManager uavControlManager; |
| | | @Resource |
| | | private UavAllManager uavAllManager; |
| | | @Resource |
| | | private TokenService tokenService; |
| | | |
| | | @Override |
| | | public void handleTextMessage(WebSocketSession session, TextMessage message) { |
| | |
| | | uavTelemetryManager.removeSubscribe(userId); |
| | | uavSignalManager.removeSubscribe(userId); |
| | | uavControlManager.removeSubscribe(userId); |
| | | |
| | | // 延迟10秒删除token(若期间没重连) |
| | | CompletableFuture.runAsync(() -> { |
| | | try { |
| | | Thread.sleep(10_000); // 延迟10秒 |
| | | } catch (InterruptedException ignored) {} |
| | | |
| | | if (!WebSocketSessionManager.containsUser(userId)) { |
| | | LoginUser loginUser = tokenService.getLoginUserByUserId(userId); |
| | | if (loginUser != null) { |
| | | tokenService.delLoginUser(loginUser.getToken(), userId); |
| | | log.info("【cmd】用户 [{}] 超时未重连,已删除 token", userId); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | | } |