增加报警数据websocket 消息推送

This commit is contained in:
15683799673
2025-09-13 09:01:39 +08:00
parent 7a6557ab3d
commit d2799a280c
6 changed files with 153 additions and 7 deletions

View File

@@ -0,0 +1,41 @@
package org.dromara.resource.api;
import org.dromara.resource.api.domain.WebSocketMsgType;
import java.util.List;
/**
* websocket 消息推送
*
* @author lxj
*/
public interface RemoteWebSocketMessageService {
/**
* 发送消息
*
* @param sessionKey session主键 一般为用户id
* @param webSocketMsgType webSocket消息类型
* @param data 消息数据
*/
void publishMessage(List<Long> sessionKey, WebSocketMsgType webSocketMsgType, Object data);
/**
* 发布订阅的消息(群发)
*
* @param webSocketMsgType webSocket消息类型
* @param data 消息数据
*/
void publishAll(WebSocketMsgType webSocketMsgType, Object data);
/**
* 向指定的用户的指定会话发送消息
*
* @param userId 要发送消息的用户id
* @param webSocketMsgType webSocket消息类型
* @param data 消息数据
*/
void sendMessage(Long userId, WebSocketMsgType webSocketMsgType, Object data);
}

View File

@@ -0,0 +1,26 @@
package org.dromara.resource.api.domain;
/**
* websocket 消息推送类型枚举
*
* @author lxj
*/
public enum WebSocketMsgType {
ALARM_MSG(100);
/**
* 消息类型编码
* 大类型 - 100,200,300,400 累加100
* 小类型 - 101 102 103 累加1
*/
private final Integer code;
WebSocketMsgType(Integer code) {
this.code = code;
}
public Integer getCode() {
return code;
}
}