Skip to content

Commit

Permalink
re-send tracks permissions after reconnected. (#128)
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudwebrtc authored Jun 14, 2022
1 parent 47cd505 commit f93f3c0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
2 changes: 2 additions & 0 deletions lib/src/core/room.dart
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ class Room extends DisposableChangeNotifier with EventsEmittable<RoomEvent> {
void _setUpEngineListeners() => _engineListener
..on<EngineConnectionStateUpdatedEvent>((event) async {
if (event.didReconnect) {
// re-send tracks permissions
localParticipant?.sendTrackSubscriptionPermissions();
events.emit(const RoomReconnectedEvent());
await _handlePostReconnect(false);
} else if (event.newState == ConnectionState.reconnecting) {
Expand Down
24 changes: 19 additions & 5 deletions lib/src/participant/local.dart
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,9 @@ class LocalParticipant extends Participant<LocalTrackPublication> {
return null;
}

bool _allParticipantsAllowed = true;
List<ParticipantTrackPermission> _participantTrackPermissions = [];

/// Control who can subscribe to LocalParticipant's published tracks.
///
/// By default, all participants can subscribe. This allows fine-grained control over
Expand All @@ -342,11 +345,22 @@ class LocalParticipant extends Participant<LocalTrackPublication> {
void setTrackSubscriptionPermissions({
required bool allParticipantsAllowed,
List<ParticipantTrackPermission> trackPermissions = const [],
}) =>
room.engine.signalClient.sendUpdateSubscriptionPermissions(
allParticipants: allParticipantsAllowed,
trackPermissions: trackPermissions.map((e) => e.toPBType()).toList(),
);
}) {
_allParticipantsAllowed = allParticipantsAllowed;
_participantTrackPermissions = trackPermissions;
sendTrackSubscriptionPermissions();
}

void sendTrackSubscriptionPermissions() {
if (room.engine.connectionState != ConnectionState.connected) {
return;
}
room.engine.signalClient.sendUpdateSubscriptionPermissions(
allParticipants: _allParticipantsAllowed,
trackPermissions:
_participantTrackPermissions.map((e) => e.toPBType()).toList(),
);
}

@internal
Iterable<lk_rtc.TrackPublishedResponse> publishedTracksInfo() =>
Expand Down

0 comments on commit f93f3c0

Please sign in to comment.