From 54d79531795d43bf45fa8d7cb2ed2d072f7f5ccd Mon Sep 17 00:00:00 2001
From: panlinlin <648540858@qq.com>
Date: Thu, 7 Jan 2021 13:15:39 +0800
Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=90=91=E4=B8=8A=E7=BA=A7?=
=?UTF-8?q?=E8=81=94->=E5=88=A0=E9=99=A4=E7=9A=84=E6=97=B6=E5=80=99?=
=?UTF-8?q?=E6=B3=A8=E9=94=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../vmp/gb28181/bean/ParentPlatformCatch.java | 10 ++
.../PlatformKeepaliveExpireEventLister.java | 1 +
.../cmd/ISIPCommanderForPlatform.java | 12 +-
.../cmd/SIPRequestHeaderPlarformProvider.java | 76 ++++++++++---
.../cmd/SIPRequestHeaderProvider.java | 106 +-----------------
.../cmd/impl/SIPCommanderFroPlatform.java | 52 ++++++++-
.../impl/RegisterResponseProcessor.java | 29 ++---
.../iot/vmp/storager/IRedisCatchStorage.java | 6 +
.../storager/impl/RedisCatchStorageImpl.java | 15 +++
.../impl/VideoManagerStoragerImpl.java | 16 +++
.../vmanager/platform/PlatformController.java | 21 +++-
11 files changed, 204 insertions(+), 140 deletions(-)
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/ParentPlatformCatch.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/ParentPlatformCatch.java
index 94e8e7f4..994039a0 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/ParentPlatformCatch.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/ParentPlatformCatch.java
@@ -10,6 +10,8 @@ public class ParentPlatformCatch {
// 注册未回复次数
private int registerAliveReply;
+ private ParentPlatform parentPlatform;
+
public String getId() {
return id;
}
@@ -33,4 +35,12 @@ public class ParentPlatformCatch {
public void setRegisterAliveReply(int registerAliveReply) {
this.registerAliveReply = registerAliveReply;
}
+
+ public ParentPlatform getParentPlatform() {
+ return parentPlatform;
+ }
+
+ public void setParentPlatform(ParentPlatform parentPlatform) {
+ this.parentPlatform = parentPlatform;
+ }
}
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/platformKeepaliveExpire/PlatformKeepaliveExpireEventLister.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/platformKeepaliveExpire/PlatformKeepaliveExpireEventLister.java
index 11f248af..a7c786e4 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/platformKeepaliveExpire/PlatformKeepaliveExpireEventLister.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/platformKeepaliveExpire/PlatformKeepaliveExpireEventLister.java
@@ -52,6 +52,7 @@ public class PlatformKeepaliveExpireEventLister implements ApplicationListener
viaHeaders = new ArrayList();
- ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(platform.getServerIP(), platform.getServerPort(), platform.getTransport(), viaTag);
- viaHeader.setRPort();
- viaHeaders.add(viaHeader);
- //from
- SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(platform.getDeviceGBId(),sipAddress);
- Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI);
- FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, fromTag);
- //to
- SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(platform.getDeviceGBId(),sipAddress);
- Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI);
- ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress,null);
-
- //callid
- CallIdHeader callIdHeader = null;
- if(platform.getTransport().equals("TCP")) {
- callIdHeader = tcpSipProvider.getNewCallId();
- }
- if(platform.getTransport().equals("UDP")) {
- callIdHeader = udpSipProvider.getNewCallId();
- }
-
- //Forwards
- MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70);
-
- //ceq
- CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(CSeq, Request.REGISTER);
- request = sipFactory.createMessageFactory().createRequest(requestLine, Request.REGISTER, callIdHeader,
- cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards);
-
- Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory()
- .createSipURI(platform.getDeviceGBId(), sipAddress));
- request.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress));
-
- ExpiresHeader expires = sipFactory.createHeaderFactory().createExpiresHeader(Integer.parseInt(platform.getExpires()));
- request.addHeader(expires);
-
- return request;
- }
-
- public Request createRegisterRequest(@NotNull ParentPlatform parentPlatform, String fromTag, String viaTag,
- String callId, String realm, String nonce, String scheme) throws ParseException, PeerUnavailableException, InvalidArgumentException {
- Request registerRequest = createRegisterRequest(parentPlatform, 2L, fromTag, viaTag);
-
- CallIdHeader callIdHeader = (CallIdHeader)registerRequest.getHeader(CallIdHeader.NAME);
- callIdHeader.setCallId(callId);
-
- String uri = "sip:" + parentPlatform.getServerGBId() +
- "@" + parentPlatform.getServerIP() +
- ":" + parentPlatform.getServerPort();
-
- String HA1 = DigestUtils.md5DigestAsHex((parentPlatform.getDeviceGBId() + ":" + realm + ":" + parentPlatform.getPassword()).getBytes());
- String HA2=DigestUtils.md5DigestAsHex((Request.REGISTER + ":" + uri).getBytes());
- String RESPONSE = DigestUtils.md5DigestAsHex((HA1 + ":" + nonce + ":" + HA2).getBytes());
-
- String authorizationHeaderContent = scheme + " username=\"" + parentPlatform.getDeviceGBId() + "\", " + "realm=\""
- + realm + "\", nonce=\"" + nonce + "\", uri=\"" + uri + "\", response=\"" + RESPONSE + "\"" + ", algorithm=MD5";
- AuthorizationHeader authorizationHeader = sipFactory.createHeaderFactory().createAuthorizationHeader(authorizationHeaderContent);
- registerRequest.addHeader(authorizationHeader);
-
- return registerRequest;
- }
-
-// public Request createKeetpaliveMessageRequest(ParentPlatform parentPlatform, String content, String fromTag, String toTag, Object o) throws PeerUnavailableException, ParseException, InvalidArgumentException {
-// Request request = null;
-// // sipuri
-// SipURI requestURI = sipFactory.createAddressFactory().createSipURI(parentPlatform.getServerGBId(), parentPlatform.getServerIP() + ":" + parentPlatform.getServerPort());
-// // via
-// ArrayList viaHeaders = new ArrayList();
-// ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(sipConfig.getSipIp(), sipConfig.getSipPort(),
-// parentPlatform.getTransport(), null);
-// viaHeader.setRPort();
-// viaHeaders.add(viaHeader);
-// // from
-// SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(parentPlatform.getServerGBId(),
-// sipConfig.getSipIp() + ":" + sipConfig.getSipPort());
-// Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI);
-// FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, fromTag);
-// // to
-// SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(parentPlatform.getServerGBId(), parentPlatform.getServerGBDomain());
-// Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI);
-// ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress, toTag);
-// // callid
-// CallIdHeader callIdHeader = parentPlatform.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId()
-// : udpSipProvider.getNewCallId();
-// // Forwards
-// MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70);
-// // ceq
-// CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(1L, Request.MESSAGE);
-//
-// request = sipFactory.createMessageFactory().createRequest(requestURI, Request.MESSAGE, callIdHeader, cSeqHeader, fromHeader,
-// toHeader, viaHeaders, maxForwards);
-// ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("APPLICATION", "MANSCDP+xml");
-// request.setContent(content, contentTypeHeader);
-// return request;
-// }
}
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java
index ecc4ed77..19ffd61f 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java
@@ -3,10 +3,13 @@ package com.genersoft.iot.vmp.gb28181.transmit.cmd.impl;
import com.genersoft.iot.vmp.conf.SipConfig;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
+import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch;
+import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.SIPRequestHeaderPlarformProvider;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.SIPRequestHeaderProvider;
+import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
@@ -16,6 +19,7 @@ import org.springframework.stereotype.Component;
import javax.sip.*;
import javax.sip.header.CallIdHeader;
+import javax.sip.header.WWWAuthenticateHeader;
import javax.sip.message.Request;
import java.text.ParseException;
import java.util.UUID;
@@ -38,6 +42,12 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
@Autowired
private IVideoManagerStorager storager;
+ @Autowired
+ private IRedisCatchStorage redisCatchStorage;
+
+ @Autowired
+ private SipSubscribe sipSubscribe;
+
@Autowired
@Qualifier(value="tcpSipProvider")
private SipProvider tcpSipProvider;
@@ -55,16 +65,29 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
}
@Override
- public boolean register(ParentPlatform parentPlatform, @Nullable String callId, @Nullable String realm, @Nullable String nonce, @Nullable String scheme ) {
+ public boolean unregister(ParentPlatform parentPlatform, SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent) {
+ parentPlatform.setExpires("0");
+ ParentPlatformCatch parentPlatformCatch = redisCatchStorage.queryPlatformCatchInfo(parentPlatform.getDeviceGBId());
+ if (parentPlatformCatch != null) {
+ parentPlatformCatch.setParentPlatform(parentPlatform);
+ redisCatchStorage.updatePlatformCatchInfo(parentPlatformCatch);
+ }
+
+ return register(parentPlatform, null, null, errorEvent, okEvent);
+ }
+
+ @Override
+ public boolean register(ParentPlatform parentPlatform, @Nullable String callId, @Nullable WWWAuthenticateHeader www, SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent) {
try {
Request request = null;
- if (realm == null || nonce == null) {
- request = headerProvider.createRegisterRequest(parentPlatform, 1L, null, null);
+
+ if (www == null ) {
+ request = headerProviderPlarformProvider.createRegisterRequest(parentPlatform, 1L, null, null);
}else {
- request = headerProvider.createRegisterRequest(parentPlatform, null, null, callId, realm, nonce, scheme);
+ request = headerProviderPlarformProvider.createRegisterRequest(parentPlatform, null, null, callId, www);
}
- transmitRequest(parentPlatform, request);
+ transmitRequest(parentPlatform, request, errorEvent, okEvent);
return true;
} catch (ParseException e) {
e.printStackTrace();
@@ -108,10 +131,29 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
}
private void transmitRequest(ParentPlatform parentPlatform, Request request) throws SipException {
+ transmitRequest(parentPlatform, request, null, null);
+ }
+
+ private void transmitRequest(ParentPlatform parentPlatform, Request request, SipSubscribe.Event errorEvent) throws SipException {
+ transmitRequest(parentPlatform, request, errorEvent, null);
+ }
+
+ private void transmitRequest(ParentPlatform parentPlatform, Request request, SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent) throws SipException {
if("TCP".equals(parentPlatform.getTransport())) {
tcpSipProvider.sendRequest(request);
} else if("UDP".equals(parentPlatform.getTransport())) {
udpSipProvider.sendRequest(request);
}
+
+ CallIdHeader callIdHeader = (CallIdHeader)request.getHeader(CallIdHeader.NAME);
+ // 添加错误订阅
+ if (errorEvent != null) {
+ sipSubscribe.addErrorSubscribe(callIdHeader.getCallId(), errorEvent);
+ }
+ // 添加订阅
+ if (okEvent != null) {
+ sipSubscribe.addOkSubscribe(callIdHeader.getCallId(), okEvent);
+ }
+
}
}
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/response/impl/RegisterResponseProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/response/impl/RegisterResponseProcessor.java
index 08857129..bfe5e3f9 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/response/impl/RegisterResponseProcessor.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/response/impl/RegisterResponseProcessor.java
@@ -22,9 +22,11 @@ import javax.sip.ResponseEvent;
import javax.sip.address.Address;
import javax.sip.address.URI;
import javax.sip.header.CallIdHeader;
+import javax.sip.header.ExpiresHeader;
import javax.sip.header.ToHeader;
import javax.sip.header.WWWAuthenticateHeader;
import javax.sip.message.Response;
+import java.util.UUID;
/**
* @Description:Register响应处理器
@@ -62,24 +64,28 @@ public class RegisterResponseProcessor implements ISIPResponseProcessor {
ToHeader toHeader = (ToHeader) response.getHeader(ToHeader.NAME);
SipUri uri = (SipUri)toHeader.getAddress().getURI();
String platformGBId = uri.getAuthority().getUser();
- logger.info(String.format("收到 %s 的注册%S请求", platformGBId, response.getStatusCode() ));
- ParentPlatform parentPlatform = storager.queryParentPlatById(platformGBId);
+ logger.info(String.format("收到 %s 的注册/注销%S响应", platformGBId, response.getStatusCode() ));
+
+ ParentPlatformCatch parentPlatformCatch = redisCatchStorage.queryPlatformCatchInfo(platformGBId);
+ if (parentPlatformCatch == null) {
+ logger.warn(String.format("收到 %s 的注册/注销%S请求, 但是平台缓存信息未查询到!!!", platformGBId, response.getStatusCode()));
+ return;
+ }
+ ParentPlatform parentPlatform = parentPlatformCatch.getParentPlatform();
if (parentPlatform == null) {
- logger.warn(String.format("收到 %s 的注册%S请求, 但是平台信息未查询到!!!", platformGBId, response.getStatusCode()));
+ logger.warn(String.format("收到 %s 的注册/注销%S请求, 但是平台信息未查询到!!!", platformGBId, response.getStatusCode()));
return;
}
if (response.getStatusCode() == 401) {
-
WWWAuthenticateHeader www = (WWWAuthenticateHeader)response.getHeader(WWWAuthenticateHeader.NAME);
- String realm = www.getRealm();
- String nonce = www.getNonce();
- String scheme = www.getScheme();
+
CallIdHeader callIdHeader = (CallIdHeader)response.getHeader(CallIdHeader.NAME);
String callId = callIdHeader.getCallId();
- sipCommanderForPlatform.register(parentPlatform, callId, realm, nonce, scheme);
+
+ sipCommanderForPlatform.register(parentPlatform, callId, www, null, null);
}else if (response.getStatusCode() == 200){
// 注册成功
logger.info(String.format("%s 注册成功", platformGBId ));
@@ -90,11 +96,8 @@ public class RegisterResponseProcessor implements ISIPResponseProcessor {
redisCatchStorage.updatePlatformKeepalive(parentPlatform);
- ParentPlatformCatch parentPlatformCatch = redisCatchStorage.queryPlatformCatchInfo(parentPlatform.getDeviceGBId());
- if (parentPlatformCatch == null) {
- parentPlatformCatch = new ParentPlatformCatch();
- parentPlatformCatch.setId(parentPlatform.getDeviceGBId());
- }
+ parentPlatformCatch.setParentPlatform(parentPlatform);
+
redisCatchStorage.updatePlatformCatchInfo(parentPlatformCatch);
}
}
diff --git a/src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java b/src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java
index 33ef2426..2e55a00e 100644
--- a/src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java
+++ b/src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java
@@ -63,8 +63,14 @@ public interface IRedisCatchStorage {
ParentPlatformCatch queryPlatformCatchInfo(String platformGbId);
+ void delPlatformCatchInfo(String platformGbId);
+
void updatePlatformKeepalive(ParentPlatform parentPlatform);
+ void delPlatformKeepalive(String platformGbId);
+
void updatePlatformRegister(ParentPlatform parentPlatform);
+ void delPlatformRegister(String platformGbId);
+
}
diff --git a/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java b/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java
index 53d34801..89eaa138 100644
--- a/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java
+++ b/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java
@@ -189,4 +189,19 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
public ParentPlatformCatch queryPlatformCatchInfo(String platformGbId) {
return (ParentPlatformCatch)redis.get(VideoManagerConstants.PLATFORM_CATCH_PREFIX + platformGbId);
}
+
+ @Override
+ public void delPlatformCatchInfo(String platformGbId) {
+ redis.del(VideoManagerConstants.PLATFORM_CATCH_PREFIX + platformGbId);
+ }
+
+ @Override
+ public void delPlatformKeepalive(String platformGbId) {
+ redis.del(VideoManagerConstants.PLATFORM_KEEPLIVEKEY_PREFIX + platformGbId);
+ }
+
+ @Override
+ public void delPlatformRegister(String platformGbId) {
+ redis.del(VideoManagerConstants.PLATFORM_REGISTER_PREFIX + platformGbId);
+ }
}
diff --git a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java
index 366032c9..92de14ae 100644
--- a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java
+++ b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java
@@ -4,6 +4,8 @@ import java.util.*;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
+import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch;
+import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper;
import com.genersoft.iot.vmp.storager.dao.DeviceMapper;
import com.genersoft.iot.vmp.storager.dao.ParentPlatformMapper;
@@ -31,6 +33,10 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
@Autowired
private ParentPlatformMapper platformMapper;
+ @Autowired
+ private IRedisCatchStorage redisCatchStorage;
+
+
/**
@@ -210,11 +216,21 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
@Override
public boolean updateParentPlatform(ParentPlatform parentPlatform) {
int result = 0;
+ ParentPlatformCatch parentPlatformCatch = redisCatchStorage.queryPlatformCatchInfo(parentPlatform.getDeviceGBId());
if ( platformMapper.getParentPlatById(parentPlatform.getDeviceGBId()) == null) {
result = platformMapper.addParentPlatform(parentPlatform);
+
+ if (parentPlatformCatch == null) {
+ parentPlatformCatch = new ParentPlatformCatch();
+ parentPlatformCatch.setParentPlatform(parentPlatform);
+ parentPlatformCatch.setId(parentPlatform.getDeviceGBId());
+ }
}else {
result = platformMapper.updateParentPlatform(parentPlatform);
}
+ // 更新缓存
+ parentPlatformCatch.setParentPlatform(parentPlatform);
+ redisCatchStorage.updatePlatformCatchInfo(parentPlatformCatch);
return result > 0;
}
diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/platform/PlatformController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/platform/PlatformController.java
index a1d3ba2b..152fa5dd 100644
--- a/src/main/java/com/genersoft/iot/vmp/vmanager/platform/PlatformController.java
+++ b/src/main/java/com/genersoft/iot/vmp/vmanager/platform/PlatformController.java
@@ -3,6 +3,7 @@ package com.genersoft.iot.vmp.vmanager.platform;
import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
+import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
import com.github.pagehelper.PageInfo;
import org.slf4j.Logger;
@@ -24,6 +25,8 @@ public class PlatformController {
@Autowired
private IVideoManagerStorager storager;
+ @Autowired
+ private IRedisCatchStorage redisCatchStorage;
@Autowired
private ISIPCommanderForPlatform commanderForPlatform;
@@ -75,7 +78,7 @@ public class PlatformController {
boolean updateResult = storager.updateParentPlatform(parentPlatform);
if (updateResult) {
- commanderForPlatform.register(parentPlatform, null, null, null, null);
+ commanderForPlatform.register(parentPlatform);
return new ResponseEntity<>("success", HttpStatus.OK);
}else {
@@ -94,7 +97,23 @@ public class PlatformController {
){
return new ResponseEntity<>("missing parameters", HttpStatus.BAD_REQUEST);
}
+
+ // 发送离线消息,
+ commanderForPlatform.unregister(parentPlatform, (event -> {
+ // 清空redis缓存
+ redisCatchStorage.delPlatformCatchInfo(parentPlatform.getDeviceGBId());
+ redisCatchStorage.delPlatformKeepalive(parentPlatform.getDeviceGBId());
+ redisCatchStorage.delPlatformRegister(parentPlatform.getDeviceGBId());
+ }), (event -> {
+ // 清空redis缓存
+ redisCatchStorage.delPlatformCatchInfo(parentPlatform.getDeviceGBId());
+ redisCatchStorage.delPlatformKeepalive(parentPlatform.getDeviceGBId());
+ redisCatchStorage.delPlatformRegister(parentPlatform.getDeviceGBId());
+ }));
+
boolean deleteResult = storager.deleteParentPlatform(parentPlatform);
+
+
if (deleteResult) {
return new ResponseEntity<>("success", HttpStatus.OK);
}else {