Commit 3962352ec32137e9561c2ba16e192f1f7fdebade

Authored by 648540858
1 parent bc82662e

优化zlm状态变化事件代码

src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
... ... @@ -444,7 +444,6 @@ public class ZLMHttpHookListener {
444 444 }
445 445 return new ResponseEntity<String>(ret.toString(),HttpStatus.OK);
446 446 }
447   -
448 447 }
449 448  
450 449 /**
... ...
src/main/java/com/genersoft/iot/vmp/media/zlm/event/ZLMOfflineEventListener.java deleted 100644 → 0
1   -package com.genersoft.iot.vmp.media.zlm.event;
2   -
3   -import com.genersoft.iot.vmp.conf.UserSetup;
4   -import com.genersoft.iot.vmp.service.IMediaServerService;
5   -import com.genersoft.iot.vmp.service.IStreamProxyService;
6   -import com.genersoft.iot.vmp.service.IStreamPushService;
7   -import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
8   -import com.genersoft.iot.vmp.utils.redis.RedisUtil;
9   -import org.slf4j.Logger;
10   -import org.slf4j.LoggerFactory;
11   -import org.springframework.beans.factory.annotation.Autowired;
12   -import org.springframework.context.ApplicationListener;
13   -import org.springframework.stereotype.Component;
14   -
15   -/**
16   - *
17   - */
18   -@Component
19   -public class ZLMOfflineEventListener implements ApplicationListener<ZLMOfflineEvent> {
20   -
21   - private final static Logger logger = LoggerFactory.getLogger(ZLMOfflineEventListener.class);
22   -
23   - @Autowired
24   - private IMediaServerService mediaServerService;
25   -
26   - @Autowired
27   - private IStreamPushService streamPushService;
28   -
29   - @Autowired
30   - private IStreamProxyService streamProxyService;
31   -
32   - @Override
33   - public void onApplicationEvent(ZLMOfflineEvent event) {
34   -
35   - logger.info("ZLM离线事件触发,ID:" + event.getMediaServerId());
36   - // 处理ZLM离线
37   - mediaServerService.zlmServerOffline(event.getMediaServerId());
38   - streamProxyService.zlmServerOffline(event.getMediaServerId());
39   - streamPushService.zlmServerOffline(event.getMediaServerId());
40   - // TODO 处理对国标的影响
41   - }
42   -}
src/main/java/com/genersoft/iot/vmp/media/zlm/event/ZLMOnlineEventListener.java renamed to src/main/java/com/genersoft/iot/vmp/media/zlm/event/ZLMStatusEventListener.java
1 1 package com.genersoft.iot.vmp.media.zlm.event;
2 2  
3   -import com.genersoft.iot.vmp.conf.SipConfig;
4   -import com.genersoft.iot.vmp.conf.UserSetup;
5 3 import com.genersoft.iot.vmp.service.IMediaServerService;
6 4 import com.genersoft.iot.vmp.service.IStreamProxyService;
7 5 import com.genersoft.iot.vmp.service.IStreamPushService;
8   -import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
9   -import com.genersoft.iot.vmp.utils.redis.RedisUtil;
10 6 import org.slf4j.Logger;
11 7 import org.slf4j.LoggerFactory;
12 8 import org.springframework.beans.factory.annotation.Autowired;
13 9 import org.springframework.context.ApplicationListener;
  10 +import org.springframework.context.event.EventListener;
  11 +import org.springframework.scheduling.annotation.Async;
14 12 import org.springframework.stereotype.Component;
15 13  
16 14 import java.text.SimpleDateFormat;
... ... @@ -23,9 +21,9 @@ import java.text.SimpleDateFormat;
23 21 * @date: 2020年5月6日 下午1:51:23
24 22 */
25 23 @Component
26   -public class ZLMOnlineEventListener implements ApplicationListener<ZLMOnlineEvent> {
  24 +public class ZLMStatusEventListener {
27 25  
28   - private final static Logger logger = LoggerFactory.getLogger(ZLMOnlineEventListener.class);
  26 + private final static Logger logger = LoggerFactory.getLogger(ZLMStatusEventListener.class);
29 27  
30 28 @Autowired
31 29 private IStreamPushService streamPushService;
... ... @@ -33,9 +31,13 @@ public class ZLMOnlineEventListener implements ApplicationListener&lt;ZLMOnlineEven
33 31 @Autowired
34 32 private IStreamProxyService streamProxyService;
35 33  
  34 + @Autowired
  35 + private IMediaServerService mediaServerService;
  36 +
36 37 private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
37 38  
38   - @Override
  39 + @Async
  40 + @EventListener
39 41 public void onApplicationEvent(ZLMOnlineEvent event) {
40 42  
41 43 logger.info("ZLM上线事件触发,ID:" + event.getMediaServerId());
... ... @@ -43,4 +45,16 @@ public class ZLMOnlineEventListener implements ApplicationListener&lt;ZLMOnlineEven
43 45 streamProxyService.zlmServerOnline(event.getMediaServerId());
44 46  
45 47 }
  48 +
  49 + @Async
  50 + @EventListener
  51 + public void onApplicationEvent(ZLMOfflineEvent event) {
  52 +
  53 + logger.info("ZLM离线事件触发,ID:" + event.getMediaServerId());
  54 + // 处理ZLM离线
  55 + mediaServerService.zlmServerOffline(event.getMediaServerId());
  56 + streamProxyService.zlmServerOffline(event.getMediaServerId());
  57 + streamPushService.zlmServerOffline(event.getMediaServerId());
  58 + // TODO 处理对国标的影响
  59 + }
46 60 }
... ...