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); +}