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 Summary
ConstructorsConstructorDescriptionNettyServerWebSocketBroadcaster(WebSocketMessageEncoder webSocketMessageEncoder, WebSocketSessionRepository webSocketSessionRepository) -
Method Summary
Modifier and TypeMethodDescription<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.<T> voidbroadcastSync(T message, MediaType mediaType, Predicate<WebSocketSession> filter) When used on the server this method will broadcast a message to all open WebSocket connections.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.micronaut.websocket.WebSocketBroadcaster
broadcast, broadcast, broadcast, broadcastAsync, broadcastAsync, broadcastAsync, broadcastAsync, broadcastSync, broadcastSync, broadcastSync
-
Constructor Details
-
NettyServerWebSocketBroadcaster
public NettyServerWebSocketBroadcaster(WebSocketMessageEncoder webSocketMessageEncoder, WebSocketSessionRepository webSocketSessionRepository) - Parameters:
webSocketMessageEncoder- An instance ofWebSocketMessageEncoderresponsible for encoding WebSocket messages.webSocketSessionRepository- An instance ofWebSocketSessionRepository. Defines a ChannelGroup repository to handle WebSockets.
-
-
Method Details
-
broadcastSync
Description copied from interface:WebSocketBroadcasterWhen used on the server this method will broadcast a message to all open WebSocket connections.- Specified by:
broadcastSyncin interfaceWebSocketBroadcaster- 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
-
broadcast
public <T> Publisher<T> broadcast(T message, MediaType mediaType, Predicate<WebSocketSession> filter) Description copied from interface:WebSocketBroadcasterWhen used on the server this method will broadcast a message to all open WebSocket connections that match the given filter. The resultingPublisherdoes not start sending until subscribed to. If you return it from Micronaut annotated methods such asOnOpenandOnMessage, Micronaut will subscribe to it and send the message without blocking.- Specified by:
broadcastin interfaceWebSocketBroadcaster- 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
Publisherthat either emits an error or emits the message once it has been published successfully.
-