voxera_signaling 0.1.0
voxera_signaling: ^0.1.0 copied to clipboard
The Voxera engine's signaling connection: session mint, WebSocket auth, acks, reconnect and push token registration. Used by the Voxera call kit.
voxera_signaling #
The Voxera engine's signaling connection for Dart. It holds no media and no UI.
Apps normally use it through a kit such as voxera_calls_kit.
import 'package:voxera_signaling/voxera_signaling.dart';
final api = VoxeraSignalApi(
baseUrl: 'https://stream.zavryn.online',
appId: '<voxera-app-id>',
appKey: '<voxera-app-key>',
);
final auth = VoxeraSignalAuth(
mint: () => api.mintSession(identity: 'user-123', name: 'Ahmed', deviceId: deviceId),
);
final client = VoxeraSignalClient(session: auth.session);
client.events
.where((event) => event.type == 'call.invitation')
.listen((event) => print(event.data['call_id']));
client.connect();
await client.whenConnected();
try {
final ack = await client.request('presence.query', {
'identities': ['user-456'],
});
print(ack['statuses']);
} on VoxeraSignalException catch (error) {
print('${error.kind}: ${error.message}');
}
Connection states #
| State | Meaning |
|---|---|
idle |
connect() was not called, or disconnect() was |
connecting |
The first attempt is running |
connected |
The engine accepted the token |
reconnecting |
The socket dropped, and the client is retrying |
closed |
The client stopped for good; closeReason says why |
A 4003 close means the session was replaced on another device or revoked. The
client does not retry it, because a new socket would be closed the same way.
Repeated authentication failures also end in closed.
A request that is in flight when the socket drops fails with
VoxeraSignalExceptionKind.disconnected. It is not sent again, because the
engine may already have acted on it.
Sessions from your own backend #
A project can turn off minting with the app key. Supply the session from your backend in that case:
final auth = VoxeraSignalAuth(mint: () async {
final body = await myBackend.fetchVoxeraSession();
return VoxeraSignalSession.fromJson(body);
});