From 764d04b497356ba6bcbb75fd42b51eca750f7223 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: 星期三, 29 五月 2024 15:02:51 +0800 Subject: [PATCH] 调整上级观看消息的发送 --- src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/KeepaliveNotifyMessageHandler.java | 21 ++++++++++++++++----- 1 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/KeepaliveNotifyMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/KeepaliveNotifyMessageHandler.java old mode 100644 new mode 100755 index 7b9f69a..034e24f --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/KeepaliveNotifyMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/KeepaliveNotifyMessageHandler.java @@ -13,6 +13,7 @@ import com.genersoft.iot.vmp.service.IDeviceService; import com.genersoft.iot.vmp.utils.DateUtil; import gov.nist.javax.sip.message.SIPRequest; +import org.apache.commons.lang3.ObjectUtils; import org.dom4j.Element; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -60,7 +61,7 @@ return; } SIPRequest request = (SIPRequest) evt.getRequest(); - logger.info("[鏀跺埌蹇冭烦]锛� device: {}, callId: {}", device.getDeviceId(), request.getCallIdHeader().getCallId()); + logger.info("[鏀跺埌蹇冭烦] device: {}, callId: {}", device.getDeviceId(), request.getCallIdHeader().getCallId()); // 鍥炲200 OK try { @@ -68,17 +69,23 @@ } catch (SipException | InvalidArgumentException | ParseException e) { logger.error("[鍛戒护鍙戦�佸け璐 蹇冭烦鍥炲: {}", e.getMessage()); } - if (DateUtil.getDifferenceForNow(device.getKeepaliveTime()) <= 3000L){ + if (!ObjectUtils.isEmpty(device.getKeepaliveTime()) && DateUtil.getDifferenceForNow(device.getKeepaliveTime()) <= 3000L) { logger.info("[鏀跺埌蹇冭烦] 蹇冭烦鍙戦�佽繃浜庨绻侊紝宸插拷鐣� device: {}, callId: {}", device.getDeviceId(), request.getCallIdHeader().getCallId()); return; } RemoteAddressInfo remoteAddressInfo = SipUtils.getRemoteAddressFromRequest(request, userSetting.getSipUseSourceIpAsRemoteAddress()); if (!device.getIp().equalsIgnoreCase(remoteAddressInfo.getIp()) || device.getPort() != remoteAddressInfo.getPort()) { - logger.info("[蹇冭烦] 璁惧{}鍦板潃鍙樺寲, 杩滅▼鍦板潃涓�: {}:{}", device.getDeviceId(), remoteAddressInfo.getIp(), remoteAddressInfo.getPort()); + logger.info("[鏀跺埌蹇冭烦] 璁惧{}鍦板潃鍙樺寲, 杩滅▼鍦板潃涓�: {}:{}", device.getDeviceId(), remoteAddressInfo.getIp(), remoteAddressInfo.getPort()); device.setPort(remoteAddressInfo.getPort()); device.setHostAddress(remoteAddressInfo.getIp().concat(":").concat(String.valueOf(remoteAddressInfo.getPort()))); device.setIp(remoteAddressInfo.getIp()); + // 璁惧鍦板潃鍙樺寲浼氬紩璧风洰褰曡闃呬换鍔″け鏁堬紝闇�瑕侀噸鏂版坊鍔� + if (device.getSubscribeCycleForCatalog() > 0) { + deviceService.removeCatalogSubscribe(device, result->{ + deviceService.addCatalogSubscribe(device); + }); + } } if (device.getKeepaliveTime() == null) { device.setKeepaliveIntervalTime(60); @@ -109,7 +116,11 @@ @Override public void handForPlatform(RequestEvent evt, ParentPlatform parentPlatform, Element element) { - // 涓嶄細鏀跺埌涓婄骇骞冲彴鐨勫績璺充俊鎭� - + // 涓埆骞冲彴淇濇椿涓嶅洖澶�200OK浼氬垽瀹氱绾� + try { + responseAck((SIPRequest) evt.getRequest(), Response.OK); + } catch (SipException | InvalidArgumentException | ParseException e) { + logger.error("[鍛戒护鍙戦�佸け璐 蹇冭烦鍥炲: {}", e.getMessage()); + } } } -- Gitblit v1.8.0