use of io.micronaut.websocket.annotation.OnClose in project micronaut-core by micronaut-projects.
the class ReactivePojoChatServerWebSocket method onClose.
// end::onmessage[]
@OnClose
public Publisher<Message> onClose(String topic, String username, WebSocketSession session) {
String text = "[" + username + "] Disconnected!";
Message message = new Message(text);
assert ServerRequestContext.currentRequest().isPresent();
return broadcaster.broadcast(message, isValid(topic, session));
}
use of io.micronaut.websocket.annotation.OnClose in project micronaut-core by micronaut-projects.
the class ReactivePojoChatServerWebSocket method onClose.
// end::onmessage[]
@OnClose
public Publisher<Message> onClose(String topic, String username, WebSocketSession session) {
String text = "[" + username + "] Disconnected!";
Message message = new Message(text);
return broadcaster.broadcast(message, isValid(topic, session));
}
use of io.micronaut.websocket.annotation.OnClose in project micronaut-core by micronaut-projects.
the class BinaryChatServerWebSocket method onClose.
@OnClose
public void onClose(String topic, String username, WebSocketSession session) {
assert ServerRequestContext.currentRequest().isPresent();
Set<? extends WebSocketSession> openSessions = session.getOpenSessions();
System.out.println("Server session closing for username = " + username);
for (WebSocketSession openSession : openSessions) {
if (isValid(topic, session, openSession)) {
String msg = "[" + username + "] Disconnected!";
System.out.println("Server sending msg = " + msg);
openSession.sendSync(msg.getBytes());
}
}
}
Aggregations