setActiveRoom method

void setActiveRoom(
  1. RoomChannel? channel
)

Implementation

void setActiveRoom(RoomChannel? channel) {
  SubscriptionIntent? previous;
  for (final intent in _intentRegistry.list()) {
    if (intent.kind == IntentKind.room) previous = intent;
  }
  final next = _intentRegistry.setActiveRoomIntent(channel);
  final channelChanged = previous?.channelName != next?.channelName;
  if (previous != null && channelChanged) {
    _record(
      SubscriptionIntentTelemetryEvent(
        kind: TelemetryEventKind.subscriptionIntentRemoved,
        at: _clock.now(),
      ),
    );
    _unsubscribeChannelIfSent(previous.channelName);
  }
  if (channelChanged) {




    _activeRoomChannel = channel;
    _activeRoomChannelName = next?.channelName;
    _activeRoomAuth = null;
    if (_presenceMembers.isNotEmpty) {
      _presenceMembers.clear();
      _emitPresenceEvent(const PresenceSnapshot({}));
    }
    _notifyActiveRoomChanged(channel);
  }
  if (next != null) {
    _record(
      SubscriptionIntentTelemetryEvent(
        kind: TelemetryEventKind.subscriptionIntentAdded,
        at: _clock.now(),
      ),
    );
    _maybeSubscribeNow();
  }
}