SocketClient class

Constructors

SocketClient({required String id, required WebSocket socket, required SocketManager manager, required Request request})

Properties

authenticatedUser Authenticatable?
no setter
authToken String?
Get authorization token from headers
no setter
handshakeRequest Request
The initial HTTP request that established the WebSocket connection. This contains the handshake headers, query parameters, and initial attributes.
final
hashCode int
The hash code for this object.
no setterinherited
headers RequestHeaders
no setter
id String
final
isAuthenticated bool
Check if client is authenticated (has user info)
no setter
manager SocketManager
final
rooms Set<String>
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
socket WebSocket
final
user Map<String, dynamic>?
Get user information from context
no setter
userAgent String?
Get user agent from headers
no setter

Methods

ack(String id, {required String event, int status = 200, dynamic data}) → void
Acknowledge a received event with optional data.
broadcast(String event, dynamic data) → void
Broadcast to all clients.
broadcastTo(String room, String event, dynamic data) → void
Broadcast to a room (excluding this client).
close([int code = 1000, String reason = '']) → void
emit(String event, dynamic data, {String? namespace}) → void
Alias for send.
get(String key) → dynamic
Gets an attribute from the handshake request context.
getHeader(String name) String?
Get any header value
getHeaderValues(String name) List<String>?
Get all values for a header
isInRoom(String room) bool
joinRoom(String room) → void
leaveRoom(String room) → void
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
send(String event, dynamic data, {String? namespace}) → void
sendError({required String message, String? id, String? event, int status = 400, Map<String, dynamic>? details}) → void
sendPacket(SocketPacket packet) → void
set(String key, dynamic value) → void
Sets an attribute on the handshake request context. These attributes are persistent for the duration of the connection and are copied to every message request context.
to(String room, String event, dynamic data) → void
Broadcast to a room (including this client).
toString() String
A string representation of this object.
inherited

Operators

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