我正在保存 webSocketSession,并在一种方法中检索该会话并向其发送消息,但在我的 websocket 客户端的 .html 文件中看不到该消息,
@Override
public Mono<Void> handle(WebSocketSession webSocketSession) {
sessions.put(webSocketSession.getId(),webSocketSession)
return webSocketSession.send(Flux.interval(Duration.ofSeconds(20)).map(i ->
webSocketSession.textMessage("MessageSentDirectly")));
}
public Mono<Void> sendNotification(String sessionId, String notificationMessage) {
WebSocketSession session = sessions.get(sessionId);
return session.send(Flux.interval(Duration.ofSeconds(1)).map(i ->
session.textMessage("MessageAfterRetreiveSession"))
}
我有一个用于 WebsocketClient 的 .html 和 .js 文件,在那个 html 文件上我可以看到 MessageSentDirectly 但我没有看到 MessageAfterRetreiveSession 字符串,
为什么我在调用 sendNotification 方法时没有在客户端收到 MessageAfterRetreiveSession?