join method
Joins the room.
Completes once the room is joined. Throws a VideoSDKError when it
is not, for example 4002 INVALID_TOKEN or 3073 ERROR_INVALID_PARAMETER for an empty room id; the room is then
released. Throws a StateError on a room that has already left —
create a new Room instead.
Implementation
Future<void> join() async {
if (_released) {
throw StateError('This Room has left; create a new Room to join again.');
}
// Refused here, so a second call never reaches the bridge while this
// room's join runs or after it joined.
if (_joining) {
throw const VideoSDKError(
code: 3055,
name: 'ERROR_OPERATION_IN_PROGRESS',
message: 'A join request is already in progress.',
);
}
if (_joinReturned) {
throw const VideoSDKError(
code: 3054,
name: 'ERROR_ALREADY_IN_REQUESTED_STATE',
message: 'You have already joined the room.',
);
}
_joining = true;
try {
await _created;
await _backend.join();
} catch (_) {
await _release();
rethrow;
} finally {
_joining = false;
}
// Left while the join ran: not joined.
if (_released) return;
_joinReturned = true;
}