增加收到notify增加或移除通道时发送redis消息

This commit is contained in:
648540858
2023-06-07 21:11:39 +08:00
parent 534be3f580
commit 0c14970ab8
3 changed files with 29 additions and 0 deletions

View File

@@ -202,4 +202,5 @@ public interface IRedisCatchStorage {
void removeAllDevice();
void sendDeviceOrChannelStatus(String deviceId, String channelId, boolean online);
void sendChannelAddOrDelete(String deviceId, String channelId, boolean add);
}

View File

@@ -611,4 +611,19 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
// 使用 RedisTemplate<Object, Object> 发送字符串消息会导致发送的消息多带了双引号
stringRedisTemplate.convertAndSend(key, msg.toString());
}
@Override
public void sendChannelAddOrDelete(String deviceId, String channelId, boolean add) {
String key = VideoManagerConstants.VM_MSG_SUBSCRIBE_DEVICE_STATUS;
logger.info("[redis通知] 推送通道{} {}/{}", add?"增加":"移除", deviceId, channelId);
StringBuilder msg = new StringBuilder();
msg.append(deviceId);
if (channelId != null) {
msg.append(":").append(channelId);
}
msg.append(" ").append(add? "ADD":"DELETE");
// 使用 RedisTemplate<Object, Object> 发送字符串消息会导致发送的消息多带了双引号
stringRedisTemplate.convertAndSend(key, msg.toString());
}
}