|
@@ -11,6 +11,8 @@ import org.jetlinks.community.media.storage.impl.RedisCacheStorageImpl;
|
|
|
import org.jetlinks.community.media.zlm.dto.MediaItem;
|
|
import org.jetlinks.community.media.zlm.dto.MediaItem;
|
|
|
import org.jetlinks.community.media.zlm.entity.MediaServerItem;
|
|
import org.jetlinks.community.media.zlm.entity.MediaServerItem;
|
|
|
import org.jetlinks.community.media.zlm.dto.OriginType;
|
|
import org.jetlinks.community.media.zlm.dto.OriginType;
|
|
|
|
|
+import org.jetlinks.core.event.EventBus;
|
|
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.server.ServerWebExchange;
|
|
import org.springframework.web.server.ServerWebExchange;
|
|
@@ -31,33 +33,33 @@ public class ZLMHttpHookListener {
|
|
|
private final LocalMediaServerItemService mediaServerItemService;
|
|
private final LocalMediaServerItemService mediaServerItemService;
|
|
|
private final RedisCacheStorageImpl redisCatchStorage;
|
|
private final RedisCacheStorageImpl redisCatchStorage;
|
|
|
private final ZLMHttpHookSubscribe subscribe;
|
|
private final ZLMHttpHookSubscribe subscribe;
|
|
|
-//
|
|
|
|
|
-// /**
|
|
|
|
|
-// * 服务器定时上报时间,上报间隔可配置,默认10s上报一次
|
|
|
|
|
-// *
|
|
|
|
|
-// */
|
|
|
|
|
-// @ResponseBody
|
|
|
|
|
-// @PostMapping(value = "/on_server_keepalive", produces = "application/json;charset=UTF-8")
|
|
|
|
|
-// public ResponseEntity<String> onServerKeepalive(@RequestBody JSONObject json){
|
|
|
|
|
-//
|
|
|
|
|
-// if (logger.isDebugEnabled()) {
|
|
|
|
|
-// logger.debug("[ ZLM HOOK ]on_server_keepalive API调用,参数:" + json.toString());
|
|
|
|
|
-// }
|
|
|
|
|
-// String mediaServerId = json.getString("mediaServerId");
|
|
|
|
|
-//
|
|
|
|
|
|
|
+ private final EventBus eventBus;
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 服务器定时上报时间,上报间隔可配置,默认10s上报一次
|
|
|
|
|
+ *
|
|
|
|
|
+ */
|
|
|
|
|
+ @ResponseBody
|
|
|
|
|
+ @PostMapping(value = "/on_server_keepalive", produces = "application/json;charset=UTF-8")
|
|
|
|
|
+ public Mono<ResponseEntity<String>> onServerKeepalive(@RequestBody JSONObject json){
|
|
|
|
|
+
|
|
|
|
|
+ if (log.isDebugEnabled()) {
|
|
|
|
|
+ log.debug("[ ZLM HOOK ]on_server_keepalive API调用,参数:" + json.toString());
|
|
|
|
|
+ }
|
|
|
// List<ZLMHttpHookSubscribe.Event> subscribes = this.subscribe.getSubscribes(ZLMHttpHookSubscribe.HookType.on_server_keepalive);
|
|
// List<ZLMHttpHookSubscribe.Event> subscribes = this.subscribe.getSubscribes(ZLMHttpHookSubscribe.HookType.on_server_keepalive);
|
|
|
// if (subscribes != null && subscribes.size() > 0) {
|
|
// if (subscribes != null && subscribes.size() > 0) {
|
|
|
// for (ZLMHttpHookSubscribe.Event subscribe : subscribes) {
|
|
// for (ZLMHttpHookSubscribe.Event subscribe : subscribes) {
|
|
|
// subscribe.response(null, json);
|
|
// subscribe.response(null, json);
|
|
|
// }
|
|
// }
|
|
|
// }
|
|
// }
|
|
|
-//
|
|
|
|
|
-// JSONObject ret = new JSONObject();
|
|
|
|
|
-// ret.put("code", 0);
|
|
|
|
|
-// ret.put("msg", "success");
|
|
|
|
|
-// return new ResponseEntity<String>(ret.toString(), HttpStatus.OK);
|
|
|
|
|
-// }
|
|
|
|
|
-//
|
|
|
|
|
|
|
+
|
|
|
|
|
+ JSONObject ret = new JSONObject();
|
|
|
|
|
+ ret.put("code", 0);
|
|
|
|
|
+ ret.put("msg", "success");
|
|
|
|
|
+ return eventBus.
|
|
|
|
|
+ publish(ZLMHttpHookSubscribe.HookType.on_server_keepalive.name(),json)
|
|
|
|
|
+ .thenReturn(ResponseEntity.ok(ret.toString()));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// /**
|
|
// /**
|
|
|
// * 流量统计事件,播放器或推流器断开时并且耗用流量超过特定阈值时会触发此事件,阈值通过配置文件general.flowThreshold配置;此事件对回复不敏感。
|
|
// * 流量统计事件,播放器或推流器断开时并且耗用流量超过特定阈值时会触发此事件,阈值通过配置文件general.flowThreshold配置;此事件对回复不敏感。
|
|
|
// *
|
|
// *
|
|
@@ -451,10 +453,11 @@ public class ZLMHttpHookListener {
|
|
|
}
|
|
}
|
|
|
String remoteAddr = exchange.getRequest().getRemoteAddress().getAddress().toString();
|
|
String remoteAddr = exchange.getRequest().getRemoteAddress().getAddress().toString();
|
|
|
jsonObject.append("ip", remoteAddr);
|
|
jsonObject.append("ip", remoteAddr);
|
|
|
- subscribe.publish(ZLMHttpHookSubscribe.HookType.on_server_started,null,jsonObject);
|
|
|
|
|
JSONObject ret = new JSONObject()
|
|
JSONObject ret = new JSONObject()
|
|
|
.append("code", 0)
|
|
.append("code", 0)
|
|
|
.append("msg", "success");
|
|
.append("msg", "success");
|
|
|
- return Mono.just(ResponseEntity.ok(ret.toString()));
|
|
|
|
|
|
|
+ return eventBus.
|
|
|
|
|
+ publish(ZLMHttpHookSubscribe.HookType.on_server_started.name(),jsonObject)
|
|
|
|
|
+ .thenReturn(ResponseEntity.ok(ret.toString()));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|