Interface WebSocketBroadcaster

All Known Implementing Classes:
NettyServerWebSocketBroadcaster

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

    Modifier and Type
    Method
    Description
    default <T> Publisher<T>
    broadcast(T message)
    When used on the server this method will broadcast a message to all open WebSocket connections.
    default <T> Publisher<T>
    broadcast(T message, MediaType mediaType)
    When used on the server this method will broadcast a message to all open WebSocket connections.
    <T> Publisher<T>
    broadcast(T message, MediaType mediaType, 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> Publisher<T>
    broadcast(T message, 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> CompletableFuture<T>
    broadcastAsync(T message)
    When used on the server this method will broadcast a message to all open WebSocket connections.
    default <T> CompletableFuture<T>
    broadcastAsync(T message, MediaType mediaType)
    When used on the server this method will broadcast a message to all open WebSocket connections.
    default <T> CompletableFuture<T>
    broadcastAsync(T message, MediaType mediaType, Predicate<WebSocketSession> filter)
    When used on the server this method will broadcast a message to all open WebSocket connections.
    default <T> CompletableFuture<T>
    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, MediaType mediaType)
    When used on the server this method will broadcast a message to all open WebSocket connections.
    default <T> void
    broadcastSync(T message, MediaType mediaType, Predicate<WebSocketSession> filter)
    When used on the server this method will broadcast a message to all open WebSocket connections.
    default <T> void
    When used on the server this method will broadcast a message to all open WebSocket connections that match the given filter.
  • Method Details

    • broadcast

      <T> Publisher<T> broadcast(T message, MediaType mediaType, 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 look up 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> Publisher<T> broadcast(T message, 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 look up 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> 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> Publisher<T> broadcast(T message, 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> CompletableFuture<T> broadcastAsync(T message, MediaType mediaType, 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 look up 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> 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> CompletableFuture<T> broadcastAsync(T message, 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> CompletableFuture<T> broadcastAsync(T message, 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 look up 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, MediaType mediaType, 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 look up 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, 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, 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 look up an appropriate codec via the MediaTypeCodecRegistry.