SocketAdapter class abstract

Abstract adapter for managing socket state (clients, rooms, broadcasts).

This allows swapping the in-memory implementation with a distributed one (e.g., Redis) for horizontal scaling.

Implementers

Constructors

SocketAdapter()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addClient(SocketClient client) → void
Add a client to the adapter.
broadcast(String event, dynamic data, {String? namespace}) → void
Broadcast an event to all clients subscribed to that event.
broadcastToRoom(String room, String event, dynamic data, {String? namespace}) → void
Broadcast an event to all clients in a room.
broadcastToRoomExcept(String room, String event, dynamic data, Set<String> excludedClientIds, {String? namespace}) → void
Broadcast an event to all clients in a room except specific ones.
getClient(String id) SocketClient?
Get a client by ID.
hasRoom(String room) bool
Check if a room exists (has active clients).
hasSubscribers(String event) bool
Check if an event has any subscribers.
isSubscribed(String event, SocketClient client) bool
Check if a client is subscribed to an event.
join(String room, SocketClient client) → void
Add a client to a room.
leave(String room, SocketClient client) → void
Remove a client from a room.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
removeClient(SocketClient client) → void
Remove a client from the adapter.
sendToUser(dynamic userId, String event, dynamic data) → void
Send a message to a specific user (by user ID). The adapter is responsible for mapping user ID to client ID(s).
sendToUsers(List userIds, String event, dynamic data) → void
Send a message to multiple specific users (by user IDs). The adapter is responsible for mapping user IDs to client ID(s).
subscribe(String event, SocketClient client) → void
Subscribe a client to a specific event channel.
subscriberCount(String event) int
Get the number of subscribers for an event.
subscriptions(SocketClient client) Set<String>
Get all events a client is subscribed to.
toString() String
A string representation of this object.
inherited
unsubscribe(String event, SocketClient client) → void
Unsubscribe a client from a specific event channel.

Operators

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