From cc793d16f5114122304573e452bcef9dd23d32c2 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: 星期四, 28 三月 2024 18:35:28 +0800 Subject: [PATCH] 调整hook订阅通知的位置 --- src/main/java/com/genersoft/iot/vmp/media/event/HookSubscribe.java | 24 ++++++++++++------------ 1 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZlmHttpHookSubscribe.java b/src/main/java/com/genersoft/iot/vmp/media/event/HookSubscribe.java similarity index 84% rename from src/main/java/com/genersoft/iot/vmp/media/zlm/ZlmHttpHookSubscribe.java rename to src/main/java/com/genersoft/iot/vmp/media/event/HookSubscribe.java index 4d1762a..14e27c3 100755 --- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZlmHttpHookSubscribe.java +++ b/src/main/java/com/genersoft/iot/vmp/media/event/HookSubscribe.java @@ -1,4 +1,4 @@ -package com.genersoft.iot.vmp.media.zlm; +package com.genersoft.iot.vmp.media.event; import com.alibaba.fastjson2.JSONObject; import com.genersoft.iot.vmp.media.zlm.dto.HookType; @@ -21,18 +21,18 @@ * @author lin */ @Component -public class ZlmHttpHookSubscribe { +public class HookSubscribe { - private final static Logger logger = LoggerFactory.getLogger(ZlmHttpHookSubscribe.class); + private final static Logger logger = LoggerFactory.getLogger(HookSubscribe.class); @FunctionalInterface public interface Event{ void response(MediaServer mediaServerItem, HookParam hookParam); } - private Map<HookType, Map<IHookSubscribe, ZlmHttpHookSubscribe.Event>> allSubscribes = new ConcurrentHashMap<>(); + private Map<HookType, Map<IHookSubscribe, HookSubscribe.Event>> allSubscribes = new ConcurrentHashMap<>(); - public void addSubscribe(IHookSubscribe hookSubscribe, ZlmHttpHookSubscribe.Event event) { + public void addSubscribe(IHookSubscribe hookSubscribe, HookSubscribe.Event event) { if (hookSubscribe.getExpires() == null) { // 榛樿5鍒嗛挓杩囨湡 Instant expiresInstant = Instant.now().plusSeconds(TimeUnit.MINUTES.toSeconds(5)); @@ -42,8 +42,8 @@ System.out.println(allSubscribes); } - public ZlmHttpHookSubscribe.Event sendNotify(HookType type, JSONObject hookResponse) { - ZlmHttpHookSubscribe.Event event= null; + public HookSubscribe.Event sendNotify(HookType type, JSONObject hookResponse) { + HookSubscribe.Event event= null; Map<IHookSubscribe, Event> eventMap = allSubscribes.get(type); if (eventMap == null) { return null; @@ -76,8 +76,8 @@ Set<Map.Entry<IHookSubscribe, Event>> entries = eventMap.entrySet(); if (entries.size() > 0) { - List<Map.Entry<IHookSubscribe, ZlmHttpHookSubscribe.Event>> entriesToRemove = new ArrayList<>(); - for (Map.Entry<IHookSubscribe, ZlmHttpHookSubscribe.Event> entry : entries) { + List<Map.Entry<IHookSubscribe, HookSubscribe.Event>> entriesToRemove = new ArrayList<>(); + for (Map.Entry<IHookSubscribe, HookSubscribe.Event> entry : entries) { JSONObject content = entry.getKey().getContent(); if (content == null || content.size() == 0) { entriesToRemove.add(entry); @@ -100,7 +100,7 @@ } if (!CollectionUtils.isEmpty(entriesToRemove)) { - for (Map.Entry<IHookSubscribe, ZlmHttpHookSubscribe.Event> entry : entriesToRemove) { + for (Map.Entry<IHookSubscribe, HookSubscribe.Event> entry : entriesToRemove) { eventMap.remove(entry.getKey()); } if (eventMap.size() == 0) { @@ -116,12 +116,12 @@ * @param type * @return */ - public List<ZlmHttpHookSubscribe.Event> getSubscribes(HookType type) { + public List<HookSubscribe.Event> getSubscribes(HookType type) { Map<IHookSubscribe, Event> eventMap = allSubscribes.get(type); if (eventMap == null) { return null; } - List<ZlmHttpHookSubscribe.Event> result = new ArrayList<>(); + List<HookSubscribe.Event> result = new ArrayList<>(); for (IHookSubscribe key : eventMap.keySet()) { result.add(eventMap.get(key)); } -- Gitblit v1.8.0