HuddleClient constructor

HuddleClient({
  1. required String projectId,
  2. bool? autoConsume,
})

Implementation

HuddleClient({
  required this.projectId,
  bool? autoConsume,
}) {
  logger.i("✅ Initializing HuddleClient");
  _audioSessionSetup().then((_) {
    logger.i("✅ audio setup completed");
  }).catchError((error) {
    logger.e("🔴 error during audio setup: $error");
  });

  //
  projectId = projectId;

  _socket = Socket.create();
  _room = Room.create(
    autoConsume: autoConsume,
  );

  _localPeer = LocalPeer.create();
  _socket.on('closed', (code) {
    logger.i('Socket Connection closed, closing the room and LocalPeer');
    if (code == ESocketCloseCode.roomClosed.value) {
      room.close(reason: 'CLOSED');
    } else if (code == ESocketCloseCode.roomEntryDenied.value) {
      room.close(reason: 'DENIED');
    } else if (code == ESocketCloseCode.connectionExpired.value) {
      logger.i('🔔 Room closed due to connection expired');
      room.close(reason: 'CONNECTION_EXPIRED');
    } else if (code == ESocketCloseCode.kicked.value) {
      room.close(reason: 'KICKED');
    } else {
      room.close();
    }
    _localPeer.close();
  });
}