sockets/socket_manager library
Classes
- ConnectLocalSocketOptions
- Options for connecting to a local socket. Supports optional authentication parameters for backend handshake.
- ConnectSocketOptions
- Options for connecting to a socket.
- DisconnectSocketOptions
- ResponseLocalConnection
- Response for local socket connection.
- ResponseLocalConnectionData
- Data received during local socket connection.
Enums
- MediaSocketConnectPhase
- Where a media socket connection attempt stopped.
Constants
-
mediaConnectionRejectionReasons
→ const List<
String> -
Reasons a media node sends with
connection-rejected { reason, stage }(media admission v2) just before it closes a refused handshake.
Functions
-
connectLocalSocket(
ConnectLocalSocketOptions options) → Future< ResponseLocalConnection> -
Connects to a media socket with the specified options.
Returns a
ResponseLocalConnectioncontaining the socket and connection data. Throws an exception if inputs are invalid or if connection fails. Example usage: -
connectSocket(
ConnectSocketOptions options) → Future< Socket> - Connects to a media socket with the specified options. Validates the API key or token and initiates a socket connection.
-
currentOnlineState(
) → bool? -
navigator.onLineon web; null elsewhere (unknown). -
describeMediaSocketError(
Object? error, {String fallback = 'Unable to connect. Check your credentials and try again.'}) → String -
User-facing text for any connection error;
fallbackfor errors that are not MediaSocketConnectException. -
disconnectSocket(
DisconnectSocketOptions options) → Future< bool> -
Disconnects the given socket instance.
Returns
trueupon successful disconnection. -
isRetryableMediaSocketError(
Object? error) → bool - False only for rejections that cannot succeed on retry with the same credentials.
-
normalizeRejectionReason(
Object? reason) → String -
Maps any reason from the server onto a known one (unknown values become
rejected-before-connection-success). -
validateApiKeyToken(
String value) → Future< bool> -
Validates the provided API key or token.
Returns
trueif the API key or token is valid, otherwise throws an exception.
Typedefs
-
ConnectLocalSocketType
= Future<
ResponseLocalConnection> Function(ConnectLocalSocketOptions options) -
ConnectSocketType
= Future<
Socket> Function(ConnectSocketOptions options) -
DisconnectSocketType
= Future<
bool> Function(DisconnectSocketOptions options)
Exceptions / Errors
- MediaSocketConnectException
-
Thrown by
connectSocketwhen the media socket cannot be used.