joinRoom method
Default method to connect to the Huddle01 Media Room. This method connects to socket, creates a room, and then connects to the room
Implementation
Future<Room?> joinRoom(
String roomId,
String token,
) async {
logger.i("Join the room with roomId, $roomId");
if (socket.connectionState == ConnectionState.connecting) {
logger.w(
"Socket is already connecting, waiting for the connection to be established",
);
return room;
}
if (room.state == RoomStates.connecting) {
logger.w('🔔 Room join already in progress');
return room;
}
if (localPeer.joined) {
logger.w("Already joined the room");
return room;
}
try {
await socket.connect(token);
logger.i("✅ Socket Connection Established");
room.roomId = roomId;
logger.i("🚪 Room Id => ${room.roomId}");
if (_session != null && await _session!.setActive(true)) {
Room room = this.room.connect();
logger.i("🚪 Room Connection Established");
return room;
} else {
logger.e("Error");
return null;
}
} catch (error) {
logger.e("🔴 Error While Joining the Room => $error");
rethrow;
}
}