From c5f2aba9b20089f184ce175b58a33a881ea9e0b1 Mon Sep 17 00:00:00 2001 From: panlinlin <648540858@qq.com> Date: 星期五, 16 四月 2021 18:23:13 +0800 Subject: [PATCH] 修复 流已经关闭后,再次调用关闭流的接口,返回超时 --- src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookSubscribe.java | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 43 insertions(+), 0 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookSubscribe.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookSubscribe.java index 995f916..bf54f50 100644 --- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookSubscribe.java +++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookSubscribe.java @@ -3,7 +3,9 @@ import com.alibaba.fastjson.JSONObject; import org.springframework.stereotype.Component; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -67,4 +69,45 @@ } return event; } + + public void removeSubscribe(HookType type, JSONObject hookResponse) { + Map<JSONObject, Event> eventMap = allSubscribes.get(type); + if (eventMap == null) { + return; + } + for (JSONObject key : eventMap.keySet()) { + Boolean result = null; + for (String s : key.keySet()) { + if (result == null) { + result = key.getString(s).equals(hookResponse.getString(s)); + }else { + result = result && key.getString(s).equals(hookResponse.getString(s)); + } + + } + if (result) { + eventMap.remove(key); + } + } + } + + /** + * 鑾峰彇鏌愪釜绫诲瀷鐨勬墍鏈夌殑璁㈤槄 + * @param type + * @return + */ + public List<ZLMHttpHookSubscribe.Event> getSubscribes(HookType type) { + // ZLMHttpHookSubscribe.Event event= null; + Map<JSONObject, Event> eventMap = allSubscribes.get(type); + if (eventMap == null) { + return null; + } + List<ZLMHttpHookSubscribe.Event> result = new ArrayList<>(); + for (JSONObject key : eventMap.keySet()) { + result.add(eventMap.get(key)); + } + return result; + } + + } -- Gitblit v1.8.0