SmartApiSocket class
A single, app-wide Socket.IO wrapper in the same spirit as SmartApiClient: configure it once via init, wire up SmartApiSocketHooks, and get connectivity-aware auto-reconnect plus a handshake/acknowledgement flow for free — no per-project socket boilerplate.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- isConnected ↔ bool
-
Whether the transport-level socket connection is currently up.
getter/setter pair
- isHandshakeComplete ↔ bool
-
Whether the handshake event (if any) has been acknowledged by the
server on the current connection.
getter/setter pair
- raw → Socket?
-
The underlying
socket_io_clientio.Socket, for anything this wrapper doesn't expose directly (rooms, ack callbacks, binary events, etc.).no setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
connect(
) → void - Manually (re)connects the socket.
-
disconnect(
) → void - Manually disconnects the socket (auto-reconnect via connectivity changes still applies unless you also call dispose).
-
dispose(
) → void - Cancels the connectivity listener and disposes the socket entirely. Call init again to start a fresh connection afterwards.
-
emit(
String event, [dynamic data]) → void -
Emits a custom
event, optionally withdata. No-ops (with a debug log) if the socket isn't currently connected. -
init(
{required String url, String? handshakeEvent, String? handshakeAckEvent, List< String> transports = const ['websocket'], int reconnectionAttempts = 15, int reconnectionDelay = 2000, Map<String, String> ? extraHeaders, bool listenToConnectivity = true}) → void -
Creates and connects the socket to
url. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
off(
String event, [void handler(dynamic error)?]) → void -
Removes listener(s) for
event— all of them, or justhandlerif one was given (seesocket_io_client'sSocket.off). -
on(
String event, void handler(dynamic data)) → void -
Registers a listener for a custom
event. -
resendHandshake(
) → Future< void> - Re-sends the handshake manually — e.g. call this right after login, once SmartApiSocketHooks.buildHandshakePayload has a real user id to return.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- instance → SmartApiSocket
-
The shared, lazily-created singleton instance.
final