Class NettyServerWebSocketBroadcaster

java.lang.Object
io.micronaut.http.netty.websocket.NettyServerWebSocketBroadcaster
All Implemented Interfaces:
WebSocketBroadcaster

@Singleton @Requires(beans=WebSocketSessionRepository.class) public class NettyServerWebSocketBroadcaster extends Object implements WebSocketBroadcaster
Netty implementation of WebSocketBroadcaster.
Since:
1.0
Author:
sdelamo
  • Constructor Details

  • Method Details

    • broadcastSync

      public <T> void broadcastSync(T message, MediaType mediaType, Predicate<WebSocketSession> filter)
      Description copied from interface: WebSocketBroadcaster
      When used on the server this method will broadcast a message to all open WebSocket connections.
      Specified by:
      broadcastSync in interface WebSocketBroadcaster
      Type Parameters:
      T - The message type
      Parameters:
      message - The message
      mediaType - The media type of the message. Used to lookup an appropriate codec via the MediaTypeCodecRegistry.
      filter - The filter
    • broadcast

      public <T> Publisher<T> broadcast(T message, MediaType mediaType, Predicate<WebSocketSession> filter)
      Description copied from interface: WebSocketBroadcaster
      When used on the server this method will broadcast a message to all open WebSocket connections that match the given filter. The resulting Publisher does not start sending until subscribed to. If you return it from Micronaut annotated methods such as OnOpen and OnMessage, Micronaut will subscribe to it and send the message without blocking.
      Specified by:
      broadcast in interface WebSocketBroadcaster
      Type Parameters:
      T - The message type
      Parameters:
      message - The message
      mediaType - The media type of the message. Used to lookup an appropriate codec via the MediaTypeCodecRegistry.
      filter - The filter to apply
      Returns:
      A Publisher that either emits an error or emits the message once it has been published successfully.