Developer guide

Reconnection

What the audio-room kit does, second by second, when a session drops.

डेवलपर्स पर वापस

Applies to: utd_audio_room_kit 3.14.1 (the live-room kit follows the same pattern; verify the numbers in its source before relying on them)

A phone loses its network, a node restarts, a tunnel cuts the signal. The session does not end at once. Three things happen, in this order.

  • The media engine tries to resume the same session by itself. This needs no code from you; the connection state is reconnecting.
  • If it cannot, the kit redials the room. Before the first redial it waits up to 8 seconds for the session to come back on its own. Every redial asks your tokenProvider for a fresh token first, because a token minted before the drop may have expired.
  • If the redials all fail, the kit calls onRejoinFailed and hands over to your app.

The redial table

Waits grow 1, 2, 4, 8, 16 seconds and then stay at 30, each with a random factor of plus or minus 20 percent so clients dropped by the same event do not come back together. The kit makes at most 10 attempts.

AttemptWait before itMoment (without dial and token time)Real wait
10 s0 sat once, after the resume window above
21 s1 s0.8 to 1.2 s
32 s3 s1.6 to 2.4 s
44 s7 s3.2 to 4.8 s
58 s15 s6.4 to 9.6 s
616 s31 s12.8 to 19.2 s
7 to 1030 s each61 s to 2 min 31 s24 to 30 s each
give upabout 2 min 31 sonRejoinFailed is called

The kit stops at once, without spending the remaining attempts, when the engine gives a final answer: a ban, a room type the project never enabled, a suspended project. A token request that fails for a transient reason (429, 5xx, timeout, no network) counts as a failed attempt and the table continues.

What the room does meanwhile

Time since the media engine disconnectedWhat the seat state does
Under 15 sLight sync: the seat state is re-read from the room.
15 to 60 sFull sync: the seat state is re-read and the seats are fetched from the engine.
Over 60 sThe controller's onForceExit callback fires so the app can tear down a dead room screen.

The 60-second onForceExit and the redial table are separate timers in 3.14.1. Decide in your onForceExit handler whether to leave the room or wait for onRejoinFailed. Behaviour of the two firing in the same drop has not been measured on a device; do not build a flow that depends on their order.

Hooks

Dart
final controller = UTDRoomController();

controller.autoRejoinEnabled = true;      // default. Set false only if your app owns recovery
controller.autoRejoinMaxAttempts = 10;    // default
controller.onRejoinFailed = () {
  // The kit has stopped trying. Show an error and leave the room.
};
controller.onForceExit = () {
  // The media session stayed disconnected for over 60 s.
};

You need a token source for any redial: set tokenProvider on the widget or on controller.tokenProvider. Without one the kit cannot redial and calls onRejoinFailed immediately. A server-side removal (a ban, a kick, a sign-in on another device) is not a drop and is never redialed.

UTD के साथ बनाने के लिए तैयार हैं?

अपना अकाउंट बनाएँ, अपने मास्टर वॉलेट को फंड करें, और अपनी ज़रूरत की सेवाएँ चालू करें।