e2e: fix resume/full-reconnect. (#194)
* fix: full re-connect. * chore: Reset fullReConnect state after ConnectionState is emitted. * Support full reconnect, fix Migration, NodeFailure, FullReconnect test cases. * revert Timeouts.connection. * update. * Refactor the resume/reconnect implementation. * more changes. * update. * Changed to simpler reconnect/recovery logic. * update. * update. * code format. * tidy. * bump version for flutter-webrtc. * chore: Remove unused exception class (SignalReconnectError). * chore: rename `fullReconnectOnNext` to `fullReconnect`. * update. * chore: Revert changes for `unpublishTrack`. * chore: Reconnect signalClient when resumeConnection. * revert `rethrow` in engine.connect. * Use removePublishedTrack instead of unpublishTrack (RemoteParticipant). * chore: Correctly handle PeerConnectionState for resume/full-reconnect. * tidy.
This commit is contained in:
@@ -240,6 +240,18 @@ class LocalParticipant extends Participant<LocalTrackPublication> {
|
||||
await pub.dispose();
|
||||
}
|
||||
|
||||
Future<void> rePublishAllTracks() async {
|
||||
final tracks = trackPublications.values.toList();
|
||||
trackPublications.clear();
|
||||
for (LocalTrackPublication track in tracks) {
|
||||
if (track.track is LocalAudioTrack) {
|
||||
await publishAudioTrack(track.track as LocalAudioTrack);
|
||||
} else if (track.track is LocalVideoTrack) {
|
||||
await publishVideoTrack(track.track as LocalVideoTrack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Publish a new data payload to the room.
|
||||
/// @param destinationSids When empty, data will be forwarded to each participant in the room.
|
||||
Future<void> publishData(
|
||||
|
||||
@@ -39,7 +39,7 @@ abstract class Participant<T extends TrackPublication>
|
||||
double audioLevel = 0;
|
||||
|
||||
/// Server assigned unique id.
|
||||
final String sid;
|
||||
String sid;
|
||||
|
||||
/// User-assigned identity.
|
||||
String identity;
|
||||
@@ -160,7 +160,7 @@ abstract class Participant<T extends TrackPublication>
|
||||
void updateFromInfo(lk_models.ParticipantInfo info) {
|
||||
identity = info.identity;
|
||||
_name = info.name;
|
||||
// participantSid = info.sid;
|
||||
sid = info.sid;
|
||||
if (info.metadata.isNotEmpty) {
|
||||
_setMetadata(info.metadata);
|
||||
}
|
||||
@@ -189,7 +189,8 @@ abstract class Participant<T extends TrackPublication>
|
||||
Future<void> unpublishTrack(String trackSid, {bool notify = true});
|
||||
|
||||
/// Convenience method to unpublish all tracks.
|
||||
Future<void> unpublishAllTracks({bool notify = true}) async {
|
||||
Future<void> unpublishAllTracks(
|
||||
{bool notify = true, bool? stopOnUnpublish}) async {
|
||||
final trackSids = trackPublications.keys.toSet();
|
||||
for (final trackid in trackSids) {
|
||||
await unpublishTrack(trackid, notify: notify);
|
||||
|
||||
@@ -180,18 +180,18 @@ class RemoteParticipant extends Participant<RemoteTrackPublication> {
|
||||
}
|
||||
}
|
||||
|
||||
// unpublish any track that is not in the info
|
||||
// remove any published track that is not in the info
|
||||
final validSids = info.tracks.map((e) => e.sid);
|
||||
final removeSids =
|
||||
trackPublications.keys.where((e) => !validSids.contains(e)).toSet();
|
||||
for (final sid in removeSids) {
|
||||
await unpublishTrack(sid);
|
||||
await removePublishedTrack(sid);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> unpublishTrack(String trackSid, {bool notify = true}) async {
|
||||
logger.finer('Unpublish track sid: $trackSid, notify: $notify');
|
||||
Future<void> removePublishedTrack(String trackSid,
|
||||
{bool notify = true}) async {
|
||||
logger.finer('removePublishedTrack track sid: $trackSid, notify: $notify');
|
||||
final pub = trackPublications.remove(trackSid);
|
||||
if (pub == null) {
|
||||
logger.warning('Publication not found $trackSid');
|
||||
@@ -220,6 +220,12 @@ class RemoteParticipant extends Participant<RemoteTrackPublication> {
|
||||
await pub.dispose();
|
||||
}
|
||||
|
||||
@Deprecated(
|
||||
'`unpublishTrack` is deprecated, use `removePublishedTrack` instead')
|
||||
@override
|
||||
Future<void> unpublishTrack(String trackSid, {bool notify = true}) =>
|
||||
removePublishedTrack(trackSid, notify: notify);
|
||||
|
||||
@internal
|
||||
lk_models.ParticipantTracks participantTracks() =>
|
||||
lk_models.ParticipantTracks(
|
||||
|
||||
Reference in New Issue
Block a user