LikeWebSocketClient class
Managed WebSocket client for the LIKE package.
Features auto-reconnect with exponential backoff and jitter, lifecycle pause/resume, token synchronization, ping-pong heartbeats, and automatic dispatch of incoming events to the LikePipeline.
Constructors
-
LikeWebSocketClient({required String url, FutureOr<
String?> getToken()?, FutureOr<String?> authTicketSupplier()?, FutureOr<void> onConnectedAuth(LikeWebSocketClient client, String token)?, bool useQueryToken = true, LikeAuthConfig? authConfig, Duration reconnectInterval = const Duration(seconds: 5), Duration maxReconnectInterval = const Duration(seconds: 60), int? maxReconnectAttempts, Duration pingInterval = const Duration(seconds: 30), String pingPayload = '{"type":"ping"}', bool pauseWhenBackgrounded = true})
Properties
- authConfig → LikeAuthConfig?
-
final
-
authTicketSupplier
→ FutureOr<
String?> Function()? -
Optional supplier for a short-lived one-time WebSocket ticket instead of
placing long-lived bearer tokens in query parameters.
final
-
connectionChanges
→ Stream<
bool> -
Connection transitions; subscribers never receive tokens or message data.
no setter
-
getToken
→ FutureOr<
String?> Function()? -
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- isConnected → bool
-
Returns true if the WebSocket is currently open.
no setter
- maxReconnectAttempts → int?
-
final
- maxReconnectInterval → Duration
-
final
- messages → Stream
-
Stream of decoded JSON/string messages received from the server.
no setter
-
onConnectedAuth
→ FutureOr<
void> Function(LikeWebSocketClient client, String token)? -
Optional callback invoked right after the socket connects so callers can
send an in-band auth frame rather than passing credentials in the URL.
final
- pauseWhenBackgrounded → bool
-
final
- pingInterval → Duration
-
final
- pingPayload → String
-
final
- reconnectInterval → Duration
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- url → String
-
final
- useQueryToken → bool
-
Whether to append the resolved token to
?token=...on the WebSocket URL.final
Methods
-
connect(
) → Future< void> - Connects to the WebSocket server sequentially.
-
disconnect(
) → Future< void> - Disconnects from the WebSocket server sequentially.
-
dispose(
) → Future< void> - Disposes of the client and cleans up resources sequentially.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
pause(
) → void - Pauses automatic reconnects while the app/tab is backgrounded.
-
resume(
) → void - Resumes reconnects and connects immediately if not already connected.
-
send(
dynamic message) → Future< void> - Sends a message down the socket channel sequentially.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited