SocketManager class
Manages WebSocket connections and events.
The SocketManager class handles WebSocket connections, manages client sessions, and facilitates communication between the server and connected clients. It also provides methods for sending messages to clients and users, handling connection events, and managing sessions.
Constructors
-
SocketManager(WaServer server, {SocketEvent? event, Map<
String, SocketEvent> routes = const {}}) - Constructs a SocketManager instance with the specified server and optional event handlers.
Properties
- countClients → int
-
Gets the count of connected clients.
no setter
- countUsers → int
-
Gets the count of unique users with active connections.
no setter
- event ↔ SocketEvent?
-
Optional SocketEvent object that contains event handlers for WebSocket connections.
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
-
routes
↔ Map<
String, SocketEvent> -
A map of routes and corresponding SocketEvent handlers.
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- server ↔ WaServer
-
The server instance associated with this SocketManager.
getter/setter pair
- session → SessionsManager
-
Manages WebSocket sessions.
final
Methods
-
addEvents(
Map< String, SocketEvent> events) → void - Adds new WebSocket events to the route map.
-
close(
) → Future - Closes all WebSocket connections and clears the session data.
-
getAllClientsKeys(
) → List< String> - Returns a list of all connected client IDs.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
requestHandel(
WebRequest rq, {String? userId}) → Future< WebRequest> - Handles an incoming WebSocket request and establishes a WebSocket connection.
-
sendToAll(
dynamic data, {int status = 200, String? path}) → Future - Sends data to all connected clients.
-
sendToClinet(
String id, dynamic data, {int status = 200, String? path}) → Future - Sends data to a specific client by ID.
-
sendToUser(
String id, dynamic data, {int status = 200, String? path}) → Future - Sends data to all clients associated with a specific user.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited