From 2ab7e9dff507a0a6fb1f88f4473c29e356028d7e Mon Sep 17 00:00:00 2001 From: shikong <919411476@qq.com> Date: Mon, 2 Oct 2023 23:28:50 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=9A=E7=94=A8=E8=AE=A2=E9=98=85=E5=99=A8He?= =?UTF-8?q?lper=20close=20=E9=94=99=E8=AF=AF=E4=BF=AE=E6=AD=A3=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=20=E9=80=9A=E7=94=A8=E5=B8=A6=E8=B6=85=E6=97=B6?= =?UTF-8?q?=E8=AE=A2=E9=98=85=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sip/message/subscribe/GenericSubscribe.java | 3 ++- .../subscribe/GenericTimeoutSubscribe.java | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 gb28181-service/src/main/java/cn/skcks/docking/gb28181/core/sip/message/subscribe/GenericTimeoutSubscribe.java diff --git a/gb28181-service/src/main/java/cn/skcks/docking/gb28181/core/sip/message/subscribe/GenericSubscribe.java b/gb28181-service/src/main/java/cn/skcks/docking/gb28181/core/sip/message/subscribe/GenericSubscribe.java index 40595ec..b205efd 100644 --- a/gb28181-service/src/main/java/cn/skcks/docking/gb28181/core/sip/message/subscribe/GenericSubscribe.java +++ b/gb28181-service/src/main/java/cn/skcks/docking/gb28181/core/sip/message/subscribe/GenericSubscribe.java @@ -4,6 +4,7 @@ import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; import java.util.Map; +import java.util.Optional; import java.util.concurrent.Executor; import java.util.concurrent.Flow; import java.util.concurrent.SubmissionPublisher; @@ -31,7 +32,7 @@ public interface GenericSubscribe { public static void delPublisher(Map> publishers, String key){ SubmissionPublisher publisher = publishers.remove(key); - publisher.close(); + Optional.ofNullable(publisher).ifPresent(SubmissionPublisher::close); } public static void addPublisher(Executor executor, Map> publishers, String key){ diff --git a/gb28181-service/src/main/java/cn/skcks/docking/gb28181/core/sip/message/subscribe/GenericTimeoutSubscribe.java b/gb28181-service/src/main/java/cn/skcks/docking/gb28181/core/sip/message/subscribe/GenericTimeoutSubscribe.java new file mode 100644 index 0000000..28ba71c --- /dev/null +++ b/gb28181-service/src/main/java/cn/skcks/docking/gb28181/core/sip/message/subscribe/GenericTimeoutSubscribe.java @@ -0,0 +1,16 @@ +package cn.skcks.docking.gb28181.core.sip.message.subscribe; + +import org.apache.commons.lang3.ArrayUtils; +import org.apache.commons.lang3.StringUtils; + +import java.util.Map; +import java.util.concurrent.Executor; +import java.util.concurrent.Flow; +import java.util.concurrent.SubmissionPublisher; +import java.util.concurrent.TimeUnit; + +public interface GenericTimeoutSubscribe extends GenericSubscribe{ + void addPublisher(String key, long time, TimeUnit timeUnit); + + void refreshPublisher(String key, long time, TimeUnit timeUnit); +}