Reconnection
What the audio-room kit does, second by second, when a session drops.
Applies to: utd_audio_room_kit 4.2.1
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
tokenProviderfor a fresh token first, because a token minted before the drop may have expired. - If the redials all fail, the kit calls
onRejoinFailedand 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.
| Attempt | Wait before it | Moment (without dial and token time) | Real wait |
|---|---|---|---|
| 1 | 0 s | 0 s | at once, after the resume window above |
| 2 | 1 s | 1 s | 0.8 to 1.2 s |
| 3 | 2 s | 3 s | 1.6 to 2.4 s |
| 4 | 4 s | 7 s | 3.2 to 4.8 s |
| 5 | 8 s | 15 s | 6.4 to 9.6 s |
| 6 | 16 s | 31 s | 12.8 to 19.2 s |
| 7 to 10 | 30 s each | 61 s to 2 min 31 s | 24 to 30 s each |
| give up | about 2 min 31 s | onRejoinFailed 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 disconnected | What the seat state does |
|---|---|
| Under 15 s | Light sync: the seat state is re-read from the room. |
| 15 to 60 s | Full sync: the seat state is re-read and the seats are fetched from the engine. |
| Over 60 s | The controller's onForceExit callback fires so the app can tear down a dead room screen. |
In utd_audio_room_kit 4.x there is no 60-second exit. The SDK redials on one schedule (4, 10, 20, 40 s, then every 60 s, with a fresh token each time). Only when that schedule gives up (20 minutes after the first drop), or the engine refuses the room or the room is closed, the kit frees the seat and calls onForceExit and onRejoinFailed together.
In utd_live_room_kit 4.0.4 the 3.x pattern is unchanged: when the room stays disconnected or reconnecting for more than 60 seconds the kit calls onForceExit, and separately a dropped session is redialed by the kit (up to 10 attempts, 1 s growing to 30 s with jitter, first waiting up to 8 s for the session to resume on its own) before onRejoinFailed. The two timers are independent; do not depend on their order.
Hooks
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 के साथ बनाने के लिए तैयार हैं?
अपना अकाउंट बनाएँ, अपने मास्टर वॉलेट को फंड करें, और अपनी ज़रूरत की सेवाएँ चालू करें।