From aeecbea7af63b045547c94086bc308ddb0fd3470 Mon Sep 17 00:00:00 2001 From: liuqingkun Date: Sun, 14 May 2023 20:52:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=97=A5=E5=BF=97,=20websock?= =?UTF-8?q?et=E6=8E=A5=E6=94=B6=E9=80=BB=E8=BE=91=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../websocket/WsChannelInboundHandler.java | 20 ++++++++++++++++++- .../org/yzh/web/endpoint/JT808Endpoint.java | 5 +++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/jtt808-server/src/main/java/io/github/yezhihao/netmc/websocket/WsChannelInboundHandler.java b/jtt808-server/src/main/java/io/github/yezhihao/netmc/websocket/WsChannelInboundHandler.java index f8b5d53..0035209 100644 --- a/jtt808-server/src/main/java/io/github/yezhihao/netmc/websocket/WsChannelInboundHandler.java +++ b/jtt808-server/src/main/java/io/github/yezhihao/netmc/websocket/WsChannelInboundHandler.java @@ -7,6 +7,7 @@ import io.netty.channel.group.ChannelGroup; import io.netty.channel.group.DefaultChannelGroup; import io.netty.handler.codec.http.websocketx.TextWebSocketFrame; import io.netty.util.concurrent.GlobalEventExecutor; +import io.netty.util.internal.StringUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.yzh.commons.constant.BusinessConstant; @@ -14,6 +15,7 @@ import org.yzh.commons.util.BusinessCacheUtil; import org.yzh.web.util.SendCommandUtil; import java.time.LocalDateTime; +import java.time.LocalTime; /** * 处理消息的handler @@ -37,6 +39,12 @@ public class WsChannelInboundHandler extends SimpleChannelInboundHandler 将要推流设备 = {} ", BusinessCacheUtil.getCurrentPushDevice(), message.getClientId()); sendCommandService.sendToDevice(message.getClientId(), null); } else { @@ -103,7 +104,7 @@ public class JT808Endpoint { // 若无正在推流的设备, 调用推流方法 SendCommandUtil.setService(sendCommandService); - if (BusinessCacheUtil.getCurrentPushDevice() == null || BusinessCacheUtil.getCurrentPushDevice() == message.getClientId()) { + if (StringUtil.isNullOrEmpty(BusinessCacheUtil.getCurrentPushDevice()) || BusinessCacheUtil.getCurrentPushDevice().equals(message.getClientId())) { log.info(BusinessConstant.LOGGER_PREFIX + " : 终端鉴权触发 - 发送推流命令 : 当前指定推流设备 = {} -> 将要推流设备 = {} ", BusinessCacheUtil.getCurrentPushDevice(), message.getClientId()); sendCommandService.sendToDevice(message.getClientId(), null); } else {