支持设备/通道状态变化时发送redis通知

This commit is contained in:
648540858
2023-04-20 10:26:42 +08:00
parent c56538813e
commit 0f50904992
7 changed files with 56 additions and 0 deletions

View File

@@ -261,4 +261,6 @@ public interface IRedisCatchStorage {
List<Device> getAllDevices();
void removeAllDevice();
void sendDeviceOrChannelStatus(String deviceId, String channelId, boolean online);
}

View File

@@ -902,4 +902,18 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
+ userSetting.getServerId() + "_*_" + id + "_*";
return RedisUtil.scan(redisTemplate, key).size();
}
@Override
public void sendDeviceOrChannelStatus(String deviceId, String channelId, boolean online) {
String key = VideoManagerConstants.VM_MSG_SUBSCRIBE_DEVICE_STATUS;
logger.info("[redis通知] 推送设备/通道状态, {}/{}-{}", deviceId, channelId, online);
StringBuilder msg = new StringBuilder();
msg.append(deviceId);
if (channelId != null) {
msg.append(":").append(channelId);
}
msg.append(" ").append(online? "ON":"OFF");
redisTemplate.convertAndSend(key, msg.toString());
}
}