Interface WebSocketBroadcaster


  • public interface WebSocketBroadcaster
    Defines WebSocket methods to broadcast messages.
    Since:
    1.0
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      default <T> org.reactivestreams.Publisher<T> broadcast​(T message)
      When used on the server this method will broadcast a message to all open WebSocket connections.
      default <T> org.reactivestreams.Publisher<T> broadcast​(T message, io.micronaut.http.MediaType mediaType)
      When used on the server this method will broadcast a message to all open WebSocket connections.
      <T> org.reactivestreams.Publisher<T> broadcast​(T message, io.micronaut.http.MediaType mediaType, java.util.function.Predicate<WebSocketSession> filter)
      When used on the server this method will broadcast a message to all open WebSocket connections that match the given filter.
      default <T> org.reactivestreams.Publisher<T> broadcast​(T message, java.util.function.Predicate<WebSocketSession> filter)
      When used on the server this method will broadcast a message to all open WebSocket connections that match the given filter.
      default <T> java.util.concurrent.CompletableFuture<T> broadcastAsync​(T message)
      When used on the server this method will broadcast a message to all open WebSocket connections.
      default <T> java.util.concurrent.CompletableFuture<T> broadcastAsync​(T message, io.micronaut.http.MediaType mediaType)
      When used on the server this method will broadcast a message to all open WebSocket connections.
      default <T> java.util.concurrent.CompletableFuture<T> broadcastAsync​(T message, io.micronaut.http.MediaType mediaType, java.util.function.Predicate<WebSocketSession> filter)
      When used on the server this method will broadcast a message to all open WebSocket connections.
      default <T> java.util.concurrent.CompletableFuture<T> broadcastAsync​(T message, java.util.function.Predicate<WebSocketSession> filter)
      When used on the server this method will broadcast a message to all open WebSocket connections that match the given filter.
      default <T> void broadcastSync​(T message)
      When used on the server this method will broadcast a message to all open WebSocket connections.
      default <T> void broadcastSync​(T message, io.micronaut.http.MediaType mediaType)
      When used on the server this method will broadcast a message to all open WebSocket connections.
      default <T> void broadcastSync​(T message, io.micronaut.http.MediaType mediaType, java.util.function.Predicate<WebSocketSession> filter)
      When used on the server this method will broadcast a message to all open WebSocket connections.
      default <T> void broadcastSync​(T message, java.util.function.Predicate<WebSocketSession> filter)
      When used on the server this method will broadcast a message to all open WebSocket connections that match the given filter.
    • Method Detail

      • broadcast

        <T> org.reactivestreams.Publisher<T> broadcast​(T message,
                                                       io.micronaut.http.MediaType mediaType,
                                                       java.util.function.Predicate<WebSocketSession> filter)
        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.
        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.
      • broadcast

        default <T> org.reactivestreams.Publisher<T> broadcast​(T message,
                                                               io.micronaut.http.MediaType mediaType)
        When used on the server this method will broadcast a message to all open WebSocket connections. 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.
        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.
        Returns:
        A Publisher that either emits an error or emits the message once it has been published successfully.
      • broadcast

        default <T> org.reactivestreams.Publisher<T> broadcast​(T message)
        When used on the server this method will broadcast a message to all open WebSocket connections. 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.
        Type Parameters:
        T - The message type
        Parameters:
        message - The message
        Returns:
        A Publisher that either emits an error or emits the message once it has been published successfully.
      • broadcast

        default <T> org.reactivestreams.Publisher<T> broadcast​(T message,
                                                               java.util.function.Predicate<WebSocketSession> filter)
        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.
        Type Parameters:
        T - The message type
        Parameters:
        message - The message
        filter - The filter to apply
        Returns:
        A Publisher that either emits an error or emits the message once it has been published successfully.
      • broadcastAsync

        default <T> java.util.concurrent.CompletableFuture<T> broadcastAsync​(T message,
                                                                             io.micronaut.http.MediaType mediaType,
                                                                             java.util.function.Predicate<WebSocketSession> filter)
        When used on the server this method will broadcast a message to all open WebSocket connections.
        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
        Returns:
        A CompletableFuture that tracks the execution. CompletableFuture.get() and related methods will return the message on success, on error throw the underlying Exception.
      • broadcastAsync

        default <T> java.util.concurrent.CompletableFuture<T> broadcastAsync​(T message)
        When used on the server this method will broadcast a message to all open WebSocket connections.
        Type Parameters:
        T - The message type
        Parameters:
        message - The message
        Returns:
        A CompletableFuture that tracks the execution. CompletableFuture.get() and related methods will return the message on success, on error throw the underlying Exception.
      • broadcastAsync

        default <T> java.util.concurrent.CompletableFuture<T> broadcastAsync​(T message,
                                                                             java.util.function.Predicate<WebSocketSession> filter)
        When used on the server this method will broadcast a message to all open WebSocket connections that match the given filter.
        Type Parameters:
        T - The message type
        Parameters:
        message - The message
        filter - The filter to apply
        Returns:
        A CompletableFuture that tracks the execution. CompletableFuture.get() and related methods will return the message on success, on error throw the underlying Exception.
      • broadcastAsync

        default <T> java.util.concurrent.CompletableFuture<T> broadcastAsync​(T message,
                                                                             io.micronaut.http.MediaType mediaType)
        When used on the server this method will broadcast a message to all open WebSocket connections.
        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.
        Returns:
        A CompletableFuture that tracks the execution. CompletableFuture.get() and related methods will return the message on success, on error throw the underlying Exception.
      • broadcastSync

        default <T> void broadcastSync​(T message,
                                       io.micronaut.http.MediaType mediaType,
                                       java.util.function.Predicate<WebSocketSession> filter)
        When used on the server this method will broadcast a message to all open WebSocket connections.
        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
      • broadcastSync

        default <T> void broadcastSync​(T message)
        When used on the server this method will broadcast a message to all open WebSocket connections.
        Type Parameters:
        T - The message type
        Parameters:
        message - The message
      • broadcastSync

        default <T> void broadcastSync​(T message,
                                       java.util.function.Predicate<WebSocketSession> filter)
        When used on the server this method will broadcast a message to all open WebSocket connections that match the given filter.
        Type Parameters:
        T - The message type
        Parameters:
        message - The message
        filter - The filter to apply
      • broadcastSync

        default <T> void broadcastSync​(T message,
                                       io.micronaut.http.MediaType mediaType)
        When used on the server this method will broadcast a message to all open WebSocket connections.
        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.