From 874b37ef35104fa8067e869ddf5458053146b519 Mon Sep 17 00:00:00 2001 From: 648540858 <456PANlinlin> Date: Tue, 16 Nov 2021 23:22:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BA=A7=E8=81=94=E6=B3=A8?= =?UTF-8?q?=E5=86=8C=E6=B6=88=E6=81=AF=E5=9B=9E=E5=A4=8D=E7=9A=84=E7=A9=BA?= =?UTF-8?q?=E6=8C=87=E9=92=88=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/vmp/gb28181/event/SipSubscribe.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/SipSubscribe.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/SipSubscribe.java index 4245bddb..f341548e 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/SipSubscribe.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/SipSubscribe.java @@ -6,6 +6,8 @@ import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import javax.sip.*; +import javax.sip.header.CallIdHeader; +import javax.sip.message.Response; import java.util.Calendar; import java.util.Date; import java.util.Map; @@ -23,6 +25,7 @@ public class SipSubscribe { private Map timeSubscribes = new ConcurrentHashMap<>(); // @Scheduled(cron="*/5 * * * * ?") //每五秒执行一次 +// @Scheduled(fixedRate= 100 * 60 * 60 ) @Scheduled(cron="0 0 * * * ?") //每小时执行一次, 每个整点 public void execute(){ logger.info("[定时任务] 清理过期的订阅信息"); @@ -58,11 +61,15 @@ public class SipSubscribe { this.event = event; if (event instanceof ResponseEvent) { ResponseEvent responseEvent = (ResponseEvent)event; - this.type = "response"; - this.msg = responseEvent.getResponse().getReasonPhrase(); - this.statusCode = responseEvent.getResponse().getStatusCode(); - this.callId = responseEvent.getDialog().getCallId().getCallId(); - this.dialog = responseEvent.getDialog(); + Response response = responseEvent.getResponse(); + this.dialog = responseEvent.getDialog(); + this.type = "response"; + if (response != null) { + this.msg = response.getReasonPhrase(); + this.statusCode = response.getStatusCode(); + } + this.callId = ((CallIdHeader)response.getHeader(CallIdHeader.NAME)).getCallId(); + }else if (event instanceof TimeoutEvent) { TimeoutEvent timeoutEvent = (TimeoutEvent)event; this.type = "timeout";