joinRoom method
join room
*token
The token issued by the developer's business server is used to ensure security.
For the generation rules, please refer to Using Token Authentication
(https://doc-zh.zego.im/article/10360), the default is an empty string, that is, no authentication.
if appSign is not passed in or if appSign is empty, this parameter must be set for authentication when logging in to a room.
Implementation
Future<ZegoRoomLoginResult> joinRoom(
String roomID, {
String token = '',
bool markAsLargeRoom = false,
bool keepWakeScreen = true,
/// Simulate entering the room, it will not really initiate the entry
/// call on express (accept offline call invitation on android, will join
/// in advance)
bool isSimulated = false,
}) async {
if (ZegoUIKitCore.shared.hasLoginSameRoom(roomID)) {
return ZegoRoomLoginResult(0, {});
}
final joinBeginTime = DateTime.now().millisecondsSinceEpoch;
final joinRoomResult = await ZegoUIKitCore.shared.joinRoom(
roomID,
token: token,
markAsLargeRoom: markAsLargeRoom,
keepWakeScreen: keepWakeScreen,
isSimulated: isSimulated,
);
if (ZegoErrorCode.CommonSuccess != joinRoomResult.errorCode) {
ZegoUIKitCore.shared.error.errorStreamCtrl?.add(ZegoUIKitError(
code: ZegoUIKitErrorCode.roomLoginError,
message: 'login room error:${joinRoomResult.errorCode}, '
'room id:$roomID, large room:$markAsLargeRoom, '
'${ZegoUIKitErrorCode.expressErrorCodeDocumentTips}',
method: 'joinRoom',
));
}
ZegoUIKit().reporter().report(
event: ZegoUIKitReporter.eventLoginRoom,
params: {
ZegoUIKitReporter.eventKeyRoomID: roomID,
ZegoUIKitReporter.eventKeyToken: token,
ZegoUIKitReporter.eventKeyStartTime: joinBeginTime,
ZegoUIKitReporter.eventKeyErrorCode: joinRoomResult.errorCode,
ZegoUIKitReporter.eventKeyErrorMsg:
joinRoomResult.extendedData.toString(),
},
);
return joinRoomResult;
}