WebSocketHub class

The global registry and manager for all active WebSocketConnections.

Use the WebSocketHub to broadcast messages to all users, specific rooms, or individual clients.

Constructors

WebSocketHub()
Internal constructor for WebSocketHub.

Properties

connections Iterable<WebSocketConnection>
Returns an iterable of all currently active WebSocketConnections.
no setter
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

broadcast(dynamic message) → void
Broadcasts a message to all active connections.
emit(String clientId, dynamic message) → void
Sends a message directly to a specific client by their clientId.
get(String id) WebSocketConnection?
Retrieves a WebSocketConnection by its unique id.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
register(WebSocketConnection connection) → void
Registers a new connection into the hub.
toRoom(String room, dynamic message) → void
Broadcasts a message to all connections currently in the specified room.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited