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
messageto all active connections. -
emit(
String clientId, dynamic message) → void -
Sends a
messagedirectly to a specific client by theirclientId. -
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
connectioninto the hub. -
toRoom(
String room, dynamic message) → void -
Broadcasts a
messageto all connections currently in the specifiedroom. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited