From d09ee0c2ff93c799b0c19481f0890a5be5a2db03 Mon Sep 17 00:00:00 2001 From: 64850858 <648540858@qq.com> Date: Fri, 18 Jun 2021 19:44:55 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=90=AF=E5=8A=A8=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E6=89=80=E6=9C=89=E8=AE=BE=E5=A4=87=E7=A6=BB=E7=BA=BF?= =?UTF-8?q?=E6=9C=AA=E5=88=A0=E9=99=A4redis=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../genersoft/iot/vmp/common/VideoManagerConstants.java | 2 +- .../java/com/genersoft/iot/vmp/conf/SipDeviceRunner.java | 2 ++ .../genersoft/iot/vmp/storager/IRedisCatchStorage.java | 5 +++++ .../iot/vmp/storager/impl/RedisCatchStorageImpl.java | 9 +++++++++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/genersoft/iot/vmp/common/VideoManagerConstants.java b/src/main/java/com/genersoft/iot/vmp/common/VideoManagerConstants.java index 6d8f45d9..5eab234b 100644 --- a/src/main/java/com/genersoft/iot/vmp/common/VideoManagerConstants.java +++ b/src/main/java/com/genersoft/iot/vmp/common/VideoManagerConstants.java @@ -16,7 +16,7 @@ public class VideoManagerConstants { public static final String CACHEKEY_PREFIX = "VMP_channel_"; - public static final String KEEPLIVEKEY_PREFIX = "VMP_keeplive_"; + public static final String KEEPLIVEKEY_PREFIX = "VMP_KEEPLIVE_"; public static final String PLAYER_PREFIX = "VMP_player_"; diff --git a/src/main/java/com/genersoft/iot/vmp/conf/SipDeviceRunner.java b/src/main/java/com/genersoft/iot/vmp/conf/SipDeviceRunner.java index fbe07c7f..62eecc67 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/SipDeviceRunner.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/SipDeviceRunner.java @@ -29,5 +29,7 @@ public class SipDeviceRunner implements CommandLineRunner { public void run(String... args) throws Exception { // 设置所有设备离线 storager.outlineForAll(); + // 设置所有设备离线 + redisCatchStorage.outlineForAll(); } } diff --git a/src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java b/src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java index be9fdffb..649fb71a 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java @@ -112,4 +112,9 @@ public interface IRedisCatchStorage { * @param deviceId 设备ID */ void clearCatchByDeviceId(String deviceId); + + /** + * 设置所有设备离线 + */ + void outlineForAll(); } diff --git a/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java b/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java index 1c6409f8..21204157 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java @@ -293,4 +293,13 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { } } } + + @Override + public void outlineForAll() { + List onlineDevices = redis.scan(String.format("%S*", VideoManagerConstants.KEEPLIVEKEY_PREFIX)); + for (int i = 0; i < onlineDevices.size(); i++) { + String key = (String) onlineDevices.get(i); + redis.del(key); + } + } }