From 4a0e9945b40e237aabd1cc41d180ca35355439ac Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Tue, 19 Mar 2024 18:47:55 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E8=8A=82=E7=82=B9=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E4=BB=A3=E7=A0=81=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../media/zlm/ZLMMediaServerStatusManger.java | 26 +++++++++++++++++++ .../zlm/event/HookZlmServerStartEvent.java | 24 +++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 src/main/java/com/genersoft/iot/vmp/media/zlm/event/HookZlmServerStartEvent.java diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaServerStatusManger.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaServerStatusManger.java index 6799cb7f..bf396900 100644 --- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaServerStatusManger.java +++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaServerStatusManger.java @@ -1,10 +1,16 @@ package com.genersoft.iot.vmp.media.zlm; import com.genersoft.iot.vmp.media.event.MediaServerChangeEvent; +import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; +import com.genersoft.iot.vmp.media.zlm.event.HookZlmServerStartEvent; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.event.EventListener; import org.springframework.scheduling.annotation.Async; +import org.springframework.scheduling.annotation.Scheduled; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; /** * 管理zlm流媒体节点的状态 @@ -13,6 +19,8 @@ public class ZLMMediaServerStatusManger { private final static Logger logger = LoggerFactory.getLogger(ZLMMediaServerStatusManger.class); + private Map offlineZlmMap = new ConcurrentHashMap<>(); + private final String type = "zlm"; @Async("taskExecutor") @@ -24,6 +32,24 @@ public class ZLMMediaServerStatusManger { return; } logger.info("[ZLM 待上线节点变化] ID:" + event.getMediaServerItem().getId()); + offlineZlmMap.put(event.getMediaServerItem().getId(), event.getMediaServerItem()); + } + + @Async("taskExecutor") + @EventListener + public void onApplicationEvent(HookZlmServerStartEvent event) { + if (event.getMediaServerItem() == null + || !type.equals(event.getMediaServerItem().getType()) + || event.getMediaServerItem().isStatus()) { + return; + } + logger.info("[ZLM-HOOK事件-服务启动] ID:" + event.getMediaServerItem().getId()); + offlineZlmMap.remove(event.getMediaServerItem().getId()); + } + + @Scheduled(fixedDelay = ) //每天的0点执行 + public void execute(){ } + } diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/event/HookZlmServerStartEvent.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/event/HookZlmServerStartEvent.java new file mode 100644 index 00000000..cbc5b74b --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/event/HookZlmServerStartEvent.java @@ -0,0 +1,24 @@ +package com.genersoft.iot.vmp.media.zlm.event; + +import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; +import org.springframework.context.ApplicationEvent; + +/** + * zlm server_start事件 + */ +public class HookZlmServerStartEvent extends ApplicationEvent { + + public HookZlmServerStartEvent(Object source) { + super(source); + } + + private MediaServerItem mediaServerItem; + + public MediaServerItem getMediaServerItem() { + return mediaServerItem; + } + + public void setMediaServerItem(MediaServerItem mediaServerItem) { + this.mediaServerItem = mediaServerItem; + } +}