SocketClusterClient class abstract

Constructors

SocketClusterClient({required String hostname, bool secure = false, int? port, String path = '/socketcluster/', Map<String, String>? query, int connectTimeout = 20000, int ackTimeout = 10000, ReconnectPolicy reconnectPolicy = const ReconnectPolicy(), String? authToken, String? clientId})
factory

Properties

ackTimeout int
The number of milliseconds to wait for the response to an invoke action. Defaults to 10000 (10s).
getter/setter pair
authState AuthenticationState
The last known authentication state of the socket.
no setter
authToken String
Changes the authentication token currently associated with the socket. Set this to null to indicate that no token should be associated with the socket.
no getter
clientId String?
The id of the socket client. This does not change between connections.
no setter
closeCode int?
Gets the close code from the underlying WebSocket which is set when the WebSocket is closed. If there is no close code available, this property will be null.
no setter
closeReason String?
Gets the close reason from the underlying WebSocket which is set when the WebSocket is closed. If there is no close reason available, this property will be null.
no setter
connectTimeout int
The number of milliseconds to wait whilst attempting a connection to the server. Defaults to 20000 (20s).
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
headers Map<String, dynamic>?
The list of headers to pass to the WebSocket server on connect.
getter/setter pair
hostname String
The hostname of the WebSocket URL to connect to.
no setter
id String?
The id of the socket connection. This is null initially and will change each time a new underlying connection is made.
no setter
path String
The path which SocketCluster uses to make the initial handshake for the WebSocket. Defaults to '/socketcluster/'
no setter
pingInterval int?
The interval in milliseconds between pings, as defined by the server upon handshaking. This will initially be null, until the handshake is complete and the value has been received from the server.
no setter
port int
The port of the WebSocket URL to connect to. Defaults to 443 if secure or 80 if not.
no setter
protocols List<String>?
The list of sub-protocols to pass to the WebSocket server on connect.
getter/setter pair
query Map<String, String>?
A map of key-value pairs which will be used as the query parameters for the initial HTTP handshake which will initiate the WebSocket connection.
no setter
reconnectPolicy ReconnectPolicy
The auto-reconnect policy to adhere to if the connection to the socket server fails. Refer to ReconnectPolicy for defaults, etc.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
secure bool
Whether or not the connection is over HTTP or HTTPS.
no setter
state ConnectionState
The current connection state of this socket.
no setter
url String
Returns the computed URL that the WebSocket client will connect to.
no setter

Methods

close([int code, String reason]) Future<void>
Cleans up local data about the socket and explicitly closes the connection to the server ensuring that the client does not attempt to automatically reconnect.
connect() Future
Connects the client socket to its origin server.
invoke(String procedure, [dynamic data, Options options = const Options(expectResponse: true)]) Future
Invoke the specified procedure (RPC) on the corresponding server-side socket. Any JSON-compatible auxiliary data may passed as data. The returned Future is the response from the server.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
on(SCEvent event, Function callback) StreamSubscription
Registers callback as an event handler for event.
onMessage(dynamic callback(String message)) StreamSubscription
Registers callback as an event handler for the message event - which is triggered whenever a message is emitted through the socket.
onRaw(dynamic callback(String data)) StreamSubscription
Registers callback as an event handler for the raw event - which is triggered whenever the server socket calls socket.send(...). The object produced will have a 'message' property.
registerProcedure(String name, dynamic callback(dynamic data)) StreamSubscription
Registers callback as a handler for the server-side transmitted remote procedure call (RPC) of name. This is essentially the reverse of the invoke function, i.e. when the server calls .invoke(...) on the client, this function's callback is called.
registerReceiver(String name, dynamic callback(dynamic data)) StreamSubscription
Registers callback as a handler for the server-side transmitted event of name. This is essentially the reverse of the transmit function, i.e. when the server calls .transmit(...) on the client, this function's callback is called.
send(String data) → void
Send some raw data to the server. This will trigger a 'raw' event on the server-side which will carry the provided data.
toString() String
A string representation of this object.
inherited
transmit(String event, [dynamic data, Options options = const Options()]) → void
Transmits the specified event to the corresponding receiver on the server-side socket. Any JSON-compatible auxiliary data may be passed as data.

Operators

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