SocketController class abstract
Base class for WebSocket controllers.
Controllers organize event handlers for a specific domain or namespace.
Constructors
Properties
- context → SocketContext
-
The current socket context.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- namespace → String
-
The namespace for this controller.
Override this to specify a custom namespace (e.g., 'chat').
Defaults to the global namespace ('/').
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
broadcast(
String event, dynamic data) → void - Helper to broadcast an event to all clients (except sender).
-
emit(
String event, dynamic data) → void - Helper to emit an event to the current client.
-
init(
) → void - Initialize event handlers.
-
join(
String room) → void - Helper to join a room.
-
leave(
String room) → void - Helper to leave a room.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
on(
String event, SocketEventHandler handler) → void - Register an event handler.
-
onData<
T> (String event, FutureOr< void> handler(SocketContext context, T data)) → void - Register a typed event handler.
-
register(
SocketRouter router) → void - Internal method to register the controller with the router.
-
to(
String room, String event, dynamic data) → void - Helper to broadcast to a specific room.
-
toString(
) → String -
A string representation of this object.
inherited
-
validate(
Map< String, String> rules, {Map<String, String> messages = const {}}) → void - Validate the payload against rules.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited