Skip to content
Live Audio Room

Fast first join

Warm up early and prefetch the token so the first room opens as fast as later ones.

The room and its seats appear as soon as the token arrives, and the media connection finishes in the background. The token request is the only thing between the tap and a populated room, so these two steps make the first join as fast as later ones.

1. Warm up early

Call this when a join becomes likely, for example when your rooms lobby opens. Without it, the first request pays for DNS and TLS, usually 100 to 300 ms on mobile networks.

// Fire and forget. Safe to call repeatedly, because everything is cached.
VoxeraRoomController.warmUp();

2. Prefetch the token on tap

Start the token request when the user taps, so it overlaps the screen transition. Then pass the controller and the future to the widget:

final controller = VoxeraRoomController()
  ..initApi(appId: appId, appKey: appKey)
  ..registerModes(myModes);
final isHost = userId == roomOwnerId;
final seatParams = VoxeraAudioRoom.resolveTokenSeatParams(
  layoutMode: layoutMode,
  isHost: isHost,
  modes: myModes,
);
final tokenFuture = controller.generateToken(
  identity: userId,
  roomName: roomId,
  roomOwnerId: roomOwnerId,
  role: isHost ? 'host' : 'audience',
  name: userName,
  seatCount: seatParams.seatCount,
  seatMode: seatParams.seatMode,
  hostSeat: seatParams.hostSeat,
  modeId: seatParams.modeId,
);
 
// Navigate, then pass both to the widget.
final room = VoxeraAudioRoom(
  appId: appId,
  appKey: appKey,
  userId: userId,
  userName: userName,
  roomId: roomId,
  roomOwnerId: roomOwnerId,
  controller: controller,
  tokenProvider: () => tokenFuture,
);

Avatars

Avatars are cached on disk after the first download. Serve resized thumbnails in your avatar URLs, for example ?w=128. The kit limits the decode size, but it can't reduce what's downloaded.