Package io.micronaut.websocket
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 TypeMethodDescriptiondefault <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>
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>
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.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
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.
-
Method Details
-
broadcast
When used on the server this method will broadcast a message to all open WebSocket connections that match the given filter. The resultingPublisher
does not start sending until subscribed to. If you return it from Micronaut annotated methods such asOnOpen
andOnMessage
, Micronaut will subscribe to it and send the message without blocking.- Type Parameters:
T
- The message type- Parameters:
message
- The messagemediaType
- The media type of the message. Used to look up an appropriate codec via theMediaTypeCodecRegistry
.filter
- The filter to apply- Returns:
- A
Publisher
that either emits an error or emits the message once it has been published successfully.
-
broadcast
When used on the server this method will broadcast a message to all open WebSocket connections. The resultingPublisher
does not start sending until subscribed to. If you return it from Micronaut annotated methods such asOnOpen
andOnMessage
, Micronaut will subscribe to it and send the message without blocking.- Type Parameters:
T
- The message type- Parameters:
message
- The messagemediaType
- The media type of the message. Used to look up an appropriate codec via theMediaTypeCodecRegistry
.- Returns:
- A
Publisher
that either emits an error or emits the message once it has been published successfully.
-
broadcast
When used on the server this method will broadcast a message to all open WebSocket connections. The resultingPublisher
does not start sending until subscribed to. If you return it from Micronaut annotated methods such asOnOpen
andOnMessage
, 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
When used on the server this method will broadcast a message to all open WebSocket connections that match the given filter. The resultingPublisher
does not start sending until subscribed to. If you return it from Micronaut annotated methods such asOnOpen
andOnMessage
, Micronaut will subscribe to it and send the message without blocking.- Type Parameters:
T
- The message type- Parameters:
message
- The messagefilter
- 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 messagemediaType
- The media type of the message. Used to look up an appropriate codec via theMediaTypeCodecRegistry
.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
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
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 messagefilter
- 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
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 messagemediaType
- The media type of the message. Used to look up an appropriate codec via theMediaTypeCodecRegistry
.- 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
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 messagemediaType
- The media type of the message. Used to look up an appropriate codec via theMediaTypeCodecRegistry
.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
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 messagefilter
- The filter to apply
-
broadcastSync
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 messagemediaType
- The media type of the message. Used to look up an appropriate codec via theMediaTypeCodecRegistry
.
-