Commit d09ee0c2ff93c799b0c19481f0890a5be5a2db03

Authored by 64850858
1 parent 513b8106

解决启动设置所有设备离线未删除redis记录

src/main/java/com/genersoft/iot/vmp/common/VideoManagerConstants.java
@@ -16,7 +16,7 @@ public class VideoManagerConstants { @@ -16,7 +16,7 @@ public class VideoManagerConstants {
16 16
17 public static final String CACHEKEY_PREFIX = "VMP_channel_"; 17 public static final String CACHEKEY_PREFIX = "VMP_channel_";
18 18
19 - public static final String KEEPLIVEKEY_PREFIX = "VMP_keeplive_"; 19 + public static final String KEEPLIVEKEY_PREFIX = "VMP_KEEPLIVE_";
20 20
21 public static final String PLAYER_PREFIX = "VMP_player_"; 21 public static final String PLAYER_PREFIX = "VMP_player_";
22 22
src/main/java/com/genersoft/iot/vmp/conf/SipDeviceRunner.java
@@ -29,5 +29,7 @@ public class SipDeviceRunner implements CommandLineRunner { @@ -29,5 +29,7 @@ public class SipDeviceRunner implements CommandLineRunner {
29 public void run(String... args) throws Exception { 29 public void run(String... args) throws Exception {
30 // 设置所有设备离线 30 // 设置所有设备离线
31 storager.outlineForAll(); 31 storager.outlineForAll();
  32 + // 设置所有设备离线
  33 + redisCatchStorage.outlineForAll();
32 } 34 }
33 } 35 }
src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java
@@ -112,4 +112,9 @@ public interface IRedisCatchStorage { @@ -112,4 +112,9 @@ public interface IRedisCatchStorage {
112 * @param deviceId 设备ID 112 * @param deviceId 设备ID
113 */ 113 */
114 void clearCatchByDeviceId(String deviceId); 114 void clearCatchByDeviceId(String deviceId);
  115 +
  116 + /**
  117 + * 设置所有设备离线
  118 + */
  119 + void outlineForAll();
115 } 120 }
src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java
@@ -293,4 +293,13 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { @@ -293,4 +293,13 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
293 } 293 }
294 } 294 }
295 } 295 }
  296 +
  297 + @Override
  298 + public void outlineForAll() {
  299 + List<Object> onlineDevices = redis.scan(String.format("%S*", VideoManagerConstants.KEEPLIVEKEY_PREFIX));
  300 + for (int i = 0; i < onlineDevices.size(); i++) {
  301 + String key = (String) onlineDevices.get(i);
  302 + redis.del(key);
  303 + }
  304 + }
296 } 305 }