Commit ff3c30f32e77aba0035583e4912723e6389d9e9f
1 parent
db865cc9
优化收到心跳设置设备上线的逻辑
Showing
12 changed files
with
30 additions
and
72 deletions
src/main/java/com/genersoft/iot/vmp/gb28181/event/DeviceOffLineDetector.java deleted
100644 → 0
| 1 | -package com.genersoft.iot.vmp.gb28181.event; | |
| 2 | - | |
| 3 | -import com.genersoft.iot.vmp.conf.UserSetting; | |
| 4 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 5 | -import org.springframework.stereotype.Component; | |
| 6 | - | |
| 7 | -import com.genersoft.iot.vmp.common.VideoManagerConstants; | |
| 8 | -import com.genersoft.iot.vmp.utils.redis.RedisUtil; | |
| 9 | - | |
| 10 | -/** | |
| 11 | - * @description:设备离在线状态检测器,用于检测设备状态 | |
| 12 | - * @author: swwheihei | |
| 13 | - * @date: 2020年5月13日 下午2:40:29 | |
| 14 | - */ | |
| 15 | -@Component | |
| 16 | -public class DeviceOffLineDetector { | |
| 17 | - | |
| 18 | - @Autowired | |
| 19 | - private RedisUtil redis; | |
| 20 | - | |
| 21 | - @Autowired | |
| 22 | - private UserSetting userSetting; | |
| 23 | - | |
| 24 | - public boolean isOnline(String deviceId) { | |
| 25 | - String key = VideoManagerConstants.KEEPLIVEKEY_PREFIX + userSetting.getServerId() + "_" + deviceId; | |
| 26 | - return redis.hasKey(key); | |
| 27 | - } | |
| 28 | -} |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java
| ... | ... | @@ -340,7 +340,7 @@ public class SIPCommander implements ISIPCommander { |
| 340 | 340 | * @param channelId 预览通道 |
| 341 | 341 | * @param event hook订阅 |
| 342 | 342 | * @param errorEvent sip错误订阅 |
| 343 | - */ | |
| 343 | + */ | |
| 344 | 344 | @Override |
| 345 | 345 | public void playStreamCmd(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, Device device, String channelId, |
| 346 | 346 | ZLMHttpHookSubscribe.Event event, SipSubscribe.Event okEvent, SipSubscribe.Event errorEvent) { | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java
| ... | ... | @@ -5,7 +5,6 @@ import com.genersoft.iot.vmp.common.VideoManagerConstants; |
| 5 | 5 | import com.genersoft.iot.vmp.conf.SipConfig; |
| 6 | 6 | import com.genersoft.iot.vmp.conf.UserSetting; |
| 7 | 7 | import com.genersoft.iot.vmp.gb28181.bean.*; |
| 8 | -import com.genersoft.iot.vmp.gb28181.event.DeviceOffLineDetector; | |
| 9 | 8 | import com.genersoft.iot.vmp.gb28181.event.EventPublisher; |
| 10 | 9 | import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent; |
| 11 | 10 | import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver; |
| ... | ... | @@ -19,7 +18,6 @@ import com.genersoft.iot.vmp.gb28181.utils.SipUtils; |
| 19 | 18 | import com.genersoft.iot.vmp.gb28181.utils.XmlUtil; |
| 20 | 19 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| 21 | 20 | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; |
| 22 | -import com.genersoft.iot.vmp.utils.GpsUtil; | |
| 23 | 21 | import com.genersoft.iot.vmp.utils.redis.RedisUtil; |
| 24 | 22 | import org.dom4j.DocumentException; |
| 25 | 23 | import org.dom4j.Element; |
| ... | ... | @@ -65,10 +63,6 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements |
| 65 | 63 | @Autowired |
| 66 | 64 | private EventPublisher publisher; |
| 67 | 65 | |
| 68 | - @Autowired | |
| 69 | - private DeviceOffLineDetector offLineDetector; | |
| 70 | - | |
| 71 | - | |
| 72 | 66 | private String method = "NOTIFY"; |
| 73 | 67 | |
| 74 | 68 | @Autowired |
| ... | ... | @@ -240,7 +234,7 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements |
| 240 | 234 | |
| 241 | 235 | // 回复200 OK |
| 242 | 236 | responseAck(evt, Response.OK); |
| 243 | - if (offLineDetector.isOnline(deviceId)) { | |
| 237 | + if (redisCatchStorage.deviceIsOnline(deviceId)) { | |
| 244 | 238 | publisher.deviceAlarmEventPublish(deviceAlarm); |
| 245 | 239 | } |
| 246 | 240 | } catch (DocumentException | SipException | InvalidArgumentException | ParseException e) { |
| ... | ... | @@ -331,7 +325,7 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements |
| 331 | 325 | |
| 332 | 326 | } |
| 333 | 327 | |
| 334 | - if (!offLineDetector.isOnline(deviceId)) { | |
| 328 | + if (!redisCatchStorage.deviceIsOnline(deviceId)) { | |
| 335 | 329 | publisher.onlineEventPublish(device, VideoManagerConstants.EVENT_ONLINE_MESSAGE); |
| 336 | 330 | } |
| 337 | 331 | } |
| ... | ... | @@ -357,10 +351,6 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements |
| 357 | 351 | public void setDeferredResultHolder(DeferredResultHolder deferredResultHolder) { |
| 358 | 352 | } |
| 359 | 353 | |
| 360 | - public void setOffLineDetector(DeviceOffLineDetector offLineDetector) { | |
| 361 | - this.offLineDetector = offLineDetector; | |
| 362 | - } | |
| 363 | - | |
| 364 | 354 | public IRedisCatchStorage getRedisCatchStorage() { |
| 365 | 355 | return redisCatchStorage; |
| 366 | 356 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java
| 1 | 1 | package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify.cmd; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSON; | |
| 4 | 3 | import com.genersoft.iot.vmp.conf.SipConfig; |
| 5 | 4 | import com.genersoft.iot.vmp.conf.UserSetting; |
| 6 | 5 | import com.genersoft.iot.vmp.gb28181.bean.*; |
| 7 | -import com.genersoft.iot.vmp.gb28181.event.DeviceOffLineDetector; | |
| 8 | 6 | import com.genersoft.iot.vmp.gb28181.event.EventPublisher; |
| 9 | 7 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; |
| 10 | 8 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; |
| ... | ... | @@ -14,7 +12,6 @@ import com.genersoft.iot.vmp.gb28181.utils.NumericUtil; |
| 14 | 12 | import com.genersoft.iot.vmp.service.IDeviceAlarmService; |
| 15 | 13 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| 16 | 14 | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; |
| 17 | -import com.genersoft.iot.vmp.utils.GpsUtil; | |
| 18 | 15 | import org.dom4j.Element; |
| 19 | 16 | import org.slf4j.Logger; |
| 20 | 17 | import org.slf4j.LoggerFactory; |
| ... | ... | @@ -59,9 +56,6 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme |
| 59 | 56 | @Autowired |
| 60 | 57 | private IDeviceAlarmService deviceAlarmService; |
| 61 | 58 | |
| 62 | - @Autowired | |
| 63 | - private DeviceOffLineDetector offLineDetector; | |
| 64 | - | |
| 65 | 59 | @Override |
| 66 | 60 | public void afterPropertiesSet() throws Exception { |
| 67 | 61 | notifyMessageHandler.addHandler(cmdType, this); |
| ... | ... | @@ -151,7 +145,7 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme |
| 151 | 145 | } |
| 152 | 146 | |
| 153 | 147 | |
| 154 | - if (offLineDetector.isOnline(device.getDeviceId())) { | |
| 148 | + if (redisCatchStorage.deviceIsOnline(device.getDeviceId())) { | |
| 155 | 149 | publisher.deviceAlarmEventPublish(deviceAlarm); |
| 156 | 150 | } |
| 157 | 151 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/KeepaliveNotifyMessageHandler.java
| ... | ... | @@ -70,7 +70,9 @@ public class KeepaliveNotifyMessageHandler extends SIPRequestProcessorParent imp |
| 70 | 70 | videoManagerStorager.updateDevice(device); |
| 71 | 71 | redisCatchStorage.updateDevice(device); |
| 72 | 72 | } |
| 73 | - publisher.onlineEventPublish(device, VideoManagerConstants.EVENT_ONLINE_KEEPLIVE); | |
| 73 | + if (!redisCatchStorage.deviceIsOnline(device.getDeviceId())) { | |
| 74 | + publisher.onlineEventPublish(device, VideoManagerConstants.EVENT_ONLINE_KEEPLIVE); | |
| 75 | + } | |
| 74 | 76 | } |
| 75 | 77 | } catch (SipException e) { |
| 76 | 78 | e.printStackTrace(); | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java
| 1 | 1 | package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.cmd; |
| 2 | 2 | |
| 3 | -import com.genersoft.iot.vmp.common.VideoManagerConstants; | |
| 4 | 3 | import com.genersoft.iot.vmp.conf.SipConfig; |
| 5 | 4 | import com.genersoft.iot.vmp.conf.UserSetting; |
| 6 | 5 | import com.genersoft.iot.vmp.gb28181.bean.*; |
| 7 | -import com.genersoft.iot.vmp.gb28181.event.DeviceOffLineDetector; | |
| 8 | 6 | import com.genersoft.iot.vmp.gb28181.event.EventPublisher; |
| 9 | 7 | import com.genersoft.iot.vmp.gb28181.session.CatalogDataCatch; |
| 10 | 8 | import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; |
| 11 | -import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; | |
| 12 | 9 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; |
| 13 | 10 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; |
| 14 | 11 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.ResponseMessageHandler; |
| ... | ... | @@ -17,8 +14,6 @@ import com.genersoft.iot.vmp.gb28181.utils.NumericUtil; |
| 17 | 14 | import com.genersoft.iot.vmp.gb28181.utils.XmlUtil; |
| 18 | 15 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| 19 | 16 | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; |
| 20 | -import com.genersoft.iot.vmp.utils.GpsUtil; | |
| 21 | -import com.genersoft.iot.vmp.vmanager.bean.WVPResult; | |
| 22 | 17 | import org.dom4j.DocumentException; |
| 23 | 18 | import org.dom4j.Element; |
| 24 | 19 | import org.slf4j.Logger; |
| ... | ... | @@ -59,9 +54,6 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp |
| 59 | 54 | private CatalogDataCatch catalogDataCatch; |
| 60 | 55 | |
| 61 | 56 | @Autowired |
| 62 | - private DeviceOffLineDetector offLineDetector; | |
| 63 | - | |
| 64 | - @Autowired | |
| 65 | 57 | private SipConfig config; |
| 66 | 58 | |
| 67 | 59 | @Autowired | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceInfoResponseMessageHandler.java
| ... | ... | @@ -4,13 +4,13 @@ import com.genersoft.iot.vmp.common.VideoManagerConstants; |
| 4 | 4 | import com.genersoft.iot.vmp.conf.SipConfig; |
| 5 | 5 | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| 6 | 6 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; |
| 7 | -import com.genersoft.iot.vmp.gb28181.event.DeviceOffLineDetector; | |
| 8 | 7 | import com.genersoft.iot.vmp.gb28181.event.EventPublisher; |
| 9 | 8 | import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; |
| 10 | 9 | import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; |
| 11 | 10 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; |
| 12 | 11 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; |
| 13 | 12 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.ResponseMessageHandler; |
| 13 | +import com.genersoft.iot.vmp.storager.IRedisCatchStorage; | |
| 14 | 14 | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; |
| 15 | 15 | import org.dom4j.DocumentException; |
| 16 | 16 | import org.dom4j.Element; |
| ... | ... | @@ -42,10 +42,10 @@ public class DeviceInfoResponseMessageHandler extends SIPRequestProcessorParent |
| 42 | 42 | private IVideoManagerStorage storager; |
| 43 | 43 | |
| 44 | 44 | @Autowired |
| 45 | - private DeferredResultHolder deferredResultHolder; | |
| 45 | + private IRedisCatchStorage redisCatchStorage; | |
| 46 | 46 | |
| 47 | 47 | @Autowired |
| 48 | - private DeviceOffLineDetector offLineDetector; | |
| 48 | + private DeferredResultHolder deferredResultHolder; | |
| 49 | 49 | |
| 50 | 50 | @Autowired |
| 51 | 51 | private SipConfig config; |
| ... | ... | @@ -82,7 +82,7 @@ public class DeviceInfoResponseMessageHandler extends SIPRequestProcessorParent |
| 82 | 82 | deferredResultHolder.invokeAllResult(msg); |
| 83 | 83 | // 回复200 OK |
| 84 | 84 | responseAck(evt, Response.OK); |
| 85 | - if (offLineDetector.isOnline(device.getDeviceId())) { | |
| 85 | + if (redisCatchStorage.deviceIsOnline(device.getDeviceId())) { | |
| 86 | 86 | publisher.onlineEventPublish(device, VideoManagerConstants.EVENT_ONLINE_MESSAGE); |
| 87 | 87 | } |
| 88 | 88 | } catch (DocumentException e) { | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceStatusResponseMessageHandler.java
| ... | ... | @@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSONObject; |
| 4 | 4 | import com.genersoft.iot.vmp.common.VideoManagerConstants; |
| 5 | 5 | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| 6 | 6 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; |
| 7 | -import com.genersoft.iot.vmp.gb28181.event.DeviceOffLineDetector; | |
| 8 | 7 | import com.genersoft.iot.vmp.gb28181.event.EventPublisher; |
| 9 | 8 | import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; |
| 10 | 9 | import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; |
| ... | ... | @@ -12,6 +11,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorP |
| 12 | 11 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; |
| 13 | 12 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.ResponseMessageHandler; |
| 14 | 13 | import com.genersoft.iot.vmp.gb28181.utils.XmlUtil; |
| 14 | +import com.genersoft.iot.vmp.storager.IRedisCatchStorage; | |
| 15 | 15 | import org.dom4j.Element; |
| 16 | 16 | import org.slf4j.Logger; |
| 17 | 17 | import org.slf4j.LoggerFactory; |
| ... | ... | @@ -34,8 +34,6 @@ public class DeviceStatusResponseMessageHandler extends SIPRequestProcessorParen |
| 34 | 34 | @Autowired |
| 35 | 35 | private ResponseMessageHandler responseMessageHandler; |
| 36 | 36 | |
| 37 | - @Autowired | |
| 38 | - private DeviceOffLineDetector offLineDetector; | |
| 39 | 37 | |
| 40 | 38 | @Autowired |
| 41 | 39 | private DeferredResultHolder deferredResultHolder; |
| ... | ... | @@ -43,6 +41,9 @@ public class DeviceStatusResponseMessageHandler extends SIPRequestProcessorParen |
| 43 | 41 | @Autowired |
| 44 | 42 | private EventPublisher publisher; |
| 45 | 43 | |
| 44 | + @Autowired | |
| 45 | + private IRedisCatchStorage redisCatchStorage; | |
| 46 | + | |
| 46 | 47 | @Override |
| 47 | 48 | public void afterPropertiesSet() throws Exception { |
| 48 | 49 | responseMessageHandler.addHandler(cmdType, this); |
| ... | ... | @@ -74,10 +75,8 @@ public class DeviceStatusResponseMessageHandler extends SIPRequestProcessorParen |
| 74 | 75 | msg.setData(json); |
| 75 | 76 | deferredResultHolder.invokeAllResult(msg); |
| 76 | 77 | |
| 77 | - if (offLineDetector.isOnline(device.getDeviceId())) { | |
| 78 | + if (redisCatchStorage.deviceIsOnline(device.getDeviceId())) { | |
| 78 | 79 | publisher.onlineEventPublish(device, VideoManagerConstants.EVENT_ONLINE_MESSAGE); |
| 79 | - } else { | |
| 80 | - | |
| 81 | 80 | } |
| 82 | 81 | } |
| 83 | 82 | ... | ... |
src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java
| ... | ... | @@ -223,4 +223,11 @@ public interface IRedisCatchStorage { |
| 223 | 223 | |
| 224 | 224 | void sendStreamPushRequestedMsg(MessageForPushChannel messageForPushChannel); |
| 225 | 225 | |
| 226 | + /** | |
| 227 | + * 判断设备状态 | |
| 228 | + * @param deviceId 设备ID | |
| 229 | + * @return | |
| 230 | + */ | |
| 231 | + public boolean deviceIsOnline(String deviceId); | |
| 232 | + | |
| 226 | 233 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java
| ... | ... | @@ -645,4 +645,10 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { |
| 645 | 645 | logger.info("[redis 报警通知] {}: {}", key, JSON.toJSON(msg)); |
| 646 | 646 | redis.convertAndSend(key, (JSONObject)JSON.toJSON(msg)); |
| 647 | 647 | } |
| 648 | + | |
| 649 | + @Override | |
| 650 | + public boolean deviceIsOnline(String deviceId) { | |
| 651 | + String key = VideoManagerConstants.KEEPLIVEKEY_PREFIX + userSetting.getServerId() + "_" + deviceId; | |
| 652 | + return redis.hasKey(key); | |
| 653 | + } | |
| 648 | 654 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java
| ... | ... | @@ -6,7 +6,6 @@ import com.genersoft.iot.vmp.gb28181.bean.Device; |
| 6 | 6 | import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; |
| 7 | 7 | import com.genersoft.iot.vmp.gb28181.bean.SubscribeHolder; |
| 8 | 8 | import com.genersoft.iot.vmp.gb28181.bean.SyncStatus; |
| 9 | -import com.genersoft.iot.vmp.gb28181.event.DeviceOffLineDetector; | |
| 10 | 9 | import com.genersoft.iot.vmp.gb28181.task.ISubscribeTask; |
| 11 | 10 | import com.genersoft.iot.vmp.gb28181.task.impl.CatalogSubscribeTask; |
| 12 | 11 | import com.genersoft.iot.vmp.gb28181.task.impl.MobilePositionSubscribeTask; |
| ... | ... | @@ -54,9 +53,6 @@ public class DeviceQuery { |
| 54 | 53 | |
| 55 | 54 | @Autowired |
| 56 | 55 | private DeferredResultHolder resultHolder; |
| 57 | - | |
| 58 | - @Autowired | |
| 59 | - private DeviceOffLineDetector offLineDetector; | |
| 60 | 56 | |
| 61 | 57 | @Autowired |
| 62 | 58 | private IDeviceService deviceService; | ... | ... |
web_src/src/components/common/jessibuca.vue
| 1 | 1 | <template> |
| 2 | - <div ref="container" @dblclick="fullscreenSwich" style="width:100%;height:100%;background-color: #eee;margin:0 auto;"> | |
| 2 | + <div ref="container" @dblclick="fullscreenSwich" style="width:100%;height:100%;background-color: #000000;margin:0 auto;"> | |
| 3 | 3 | <div class="buttons-box" id="buttonsBox"> |
| 4 | 4 | <div class="buttons-box-left"> |
| 5 | 5 | <i v-if="!playing" class="iconfont icon-play jessibuca-btn" @click="playBtnClick"></i> | ... | ... |