Class ServletWebSocketSessionRegistry

java.lang.Object
io.micronaut.servlet.websocket.ServletWebSocketSessionRegistry
All Implemented Interfaces:
io.micronaut.context.event.ApplicationEventListener<io.micronaut.runtime.server.event.ServerShutdownEvent>, EventListener

@Internal @Singleton public final class ServletWebSocketSessionRegistry extends Object implements io.micronaut.context.event.ApplicationEventListener<io.micronaut.runtime.server.event.ServerShutdownEvent>
Keeps track of the open WebSocket sessions of this server.

The Netty server tracks sessions in a single Netty ChannelGroup that spans every endpoint, and both WebSocketSession.getOpenSessions() and the broadcaster are built on it. This registry plays the same role, since the per-endpoint set offered by jakarta.websocket.Session#getOpenSessions() has narrower scope.

Since:
6.2.0
Author:
graemerocher
  • Constructor Details

    • ServletWebSocketSessionRegistry

      public ServletWebSocketSessionRegistry()
  • Method Details

    • getOpenSessions

      public Set<io.micronaut.websocket.WebSocketSession> getOpenSessions()
      Returns:
      The currently open sessions
    • onApplicationEvent

      public void onApplicationEvent(io.micronaut.runtime.server.event.ServerShutdownEvent event)
      Specified by:
      onApplicationEvent in interface io.micronaut.context.event.ApplicationEventListener<io.micronaut.runtime.server.event.ServerShutdownEvent>