updateSubscriptionAllowed method
Implementation
@internal
// Update internal var and return true if changed
Future<bool> updateSubscriptionAllowed(bool allowed) async {
if (_subscriptionAllowed == allowed) return false;
_subscriptionAllowed = allowed;
logger.fine('updateSubscriptionAllowed allowed: ${allowed}');
// emit events
[
participant.events,
].emit(TrackSubscriptionPermissionChangedEvent(
participant: participant,
publication: this,
state: subscriptionState,
));
if (!_subscriptionAllowed && super.subscribed /* track != null */) {
// Ideally, we should wait for WebRTC's onRemoveTrack event
// but it does not work reliably across platforms.
// So for now we will assume remove track succeeded.
[participant.events, participant.room.events].emit(TrackUnsubscribedEvent(
participant: participant,
track: track!,
publication: this,
));
// Simply set to null for now
await updateTrack(null);
}
return true;
}