feat(property): 用 Server-Sent Events (SSE) 替代 WebSocket 实现消息推送
This commit is contained in:
@@ -23,4 +23,13 @@ public interface RemoteMessageService {
|
||||
* @param message 消息内容
|
||||
*/
|
||||
void publishAll(String message);
|
||||
|
||||
/**
|
||||
* 向指定的用户的指定会话发送消息
|
||||
*
|
||||
* @param userId 要发送消息的用户id
|
||||
* @param token 用户的会话令牌
|
||||
* @param message 要发送的消息内容
|
||||
*/
|
||||
void sendMessage(Long userId, String token, String message);
|
||||
}
|
||||
|
@@ -44,4 +44,20 @@ public class RemoteMessageServiceStub implements RemoteMessageService {
|
||||
log.warn("推送功能未开启或服务未找到");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 向指定的用户的指定会话发送消息
|
||||
*
|
||||
* @param userId 要发送消息的用户id
|
||||
* @param token 用户的会话令牌
|
||||
* @param message 要发送的消息内容
|
||||
*/
|
||||
@Override
|
||||
public void sendMessage(Long userId, String token, String message) {
|
||||
try {
|
||||
remoteMessageService.sendMessage(userId, token, message);
|
||||
} catch (Exception e) {
|
||||
log.warn("推送功能未开启或服务未找到");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user