realtime library

Typed server events from Thoth, as Dart streams.

A second entrypoint so an application that only makes HTTP requests never imports the socket code: package:horus_client/horus_client.dart stays an HTTP runtime.

Classes

ChannelEvent<T>
One typed event on one channel: the realtime twin of Endpoint<T>.
Endpoint<T>
Transport details for one generated API method.
HorusClient
Small cross-platform HTTP runtime used by generated Maat clients.
HorusRealtime
Typed server events from Thoth, as Dart streams.
RealtimeFrame
One Pusher-protocol frame, in the shape Thoth actually puts on the wire.
RealtimeSocket
The socket HorusRealtime talks through.

Enums

RealtimeStatus
Where the connection is, for a banner or a retry button.

Functions

connectWebSocket(Uri uri) Future<RealtimeSocket>
The default transport: package:web_socket_channel, which picks the browser or the IO implementation, so the same code runs in Flutter web, mobile and desktop.
exponentialBackoff({Duration base = const Duration(milliseconds: 500), Duration cap = const Duration(seconds: 30), Random? random}) Backoff
Exponential backoff with full jitter.

Typedefs

Backoff = Duration Function(int attempt)
How long to wait before reconnect attempt attempt (1 is the first).
HeadersProvider = Future<Map<String, String>> Function()
Headers computed per request — a bearer token that expires, for one.
JsonDecoder<T> = T Function(Object? json)
RealtimeTransport = Future<RealtimeSocket> Function(Uri uri)
SocketIdProvider = String? Function()
The id of the live realtime connection, or null when there is none.

Exceptions / Errors

ChannelAuthorizationException
A private or presence channel the application refused to authorize.
HorusClientException