diff --git a/example/lib/pages/connect.dart b/example/lib/pages/connect.dart index e04c65a..8483e9e 100644 --- a/example/lib/pages/connect.dart +++ b/example/lib/pages/connect.dart @@ -39,6 +39,7 @@ class _ConnectPageState extends State { super.dispose(); } + // Read saved URL and Token Future _readPrefs() async { final prefs = await SharedPreferences.getInstance(); _uriCtrl.text = prefs.getString(_storeKeyUri) ?? ''; @@ -48,6 +49,7 @@ class _ConnectPageState extends State { }); } + // Save URL and Token Future _writePrefs() async { final prefs = await SharedPreferences.getInstance(); await prefs.setString(_storeKeyUri, _uriCtrl.text); @@ -62,12 +64,14 @@ class _ConnectPageState extends State { _busy = true; }); - // Save for next time + // Save URL and Token for convenience await _writePrefs(); - print( - 'Connecting with url: ${_uriCtrl.text}, token: ${_tokenCtrl.text}...'); + print('Connecting with url: ${_uriCtrl.text}, ' + 'token: ${_tokenCtrl.text}...'); + // Try to connect to a room + // This will throw an Exception if it fails for any reason. final room = await LiveKitClient.connect( _uriCtrl.text, _tokenCtrl.text, @@ -83,7 +87,7 @@ class _ConnectPageState extends State { MaterialPageRoute(builder: (_) => RoomPage(room)), ); } catch (error) { - print('could not connect $error'); + print('Could not connect $error'); await ctx.showErrorDialog(error); } finally { setState(() { @@ -97,7 +101,6 @@ class _ConnectPageState extends State { setState(() { _simulcast = value; }); - // await _writePrefs(); } @override diff --git a/lib/src/events.dart b/lib/src/events.dart index f365e64..f222de1 100644 --- a/lib/src/events.dart +++ b/lib/src/events.dart @@ -133,7 +133,7 @@ class TrackUnsubscribedEvent with RoomEvent, ParticipantEvent { } /// A Participant has muted one of the track. -/// Emitted on [RemoteParticipant] and [LocalParticipant]. +/// Emitted by [RemoteParticipant] and [LocalParticipant]. class TrackMutedEvent with RoomEvent, ParticipantEvent { final Participant participant; final TrackPublication track; @@ -144,7 +144,7 @@ class TrackMutedEvent with RoomEvent, ParticipantEvent { } /// This participant has unmuted one of their tracks -/// Emitted on [RemoteParticipant] and [LocalParticipant]. +/// Emitted by [RemoteParticipant] and [LocalParticipant]. class TrackUnmutedEvent with RoomEvent, ParticipantEvent { final Participant participant; final TrackPublication track; @@ -154,14 +154,10 @@ class TrackUnmutedEvent with RoomEvent, ParticipantEvent { }); } -// -// common events for both Room/Participant. -// - /// Participant metadata is a simple way for app-specific state to be pushed to /// all users. When RoomService.UpdateParticipantMetadata is called to change a /// [Participant]'s state, *all* [Participant]s in the room will fire this event. -/// Emitted on [Participant]. +/// Emitted by [Room] and [Participant]. class ParticipantMetadataUpdatedEvent with RoomEvent, ParticipantEvent { final Participant participant; const ParticipantMetadataUpdatedEvent({ @@ -172,7 +168,7 @@ class ParticipantMetadataUpdatedEvent with RoomEvent, ParticipantEvent { /// Data received from [RemoteParticipant]. /// Data packets provides the ability to use LiveKit to send/receive arbitrary /// payloads. -/// Emitted on [Room] and [RemoteParticipant]. +/// Emitted by [Room] and [RemoteParticipant]. class DataReceivedEvent with RoomEvent, ParticipantEvent { /// Sender of the data. This may be null if data is sent from Server API. final RemoteParticipant? participant; @@ -184,7 +180,7 @@ class DataReceivedEvent with RoomEvent, ParticipantEvent { } /// The participant's isSpeaking property has changed -/// Emitted on [Participant]. +/// Emitted by [Participant]. class SpeakingChangedEvent with ParticipantEvent { final Participant participant; final bool speaking; diff --git a/lib/src/options.dart b/lib/src/options.dart index edf8803..e0cb9d4 100644 --- a/lib/src/options.dart +++ b/lib/src/options.dart @@ -3,8 +3,11 @@ import 'track/options.dart'; /// Options when joining a room. /// {@category Room} class ConnectOptions { + /// Auto-subscribe to room tracks upon connect, defaults to true. final bool autoSubscribe; + + /// Default options used when publishing a track final TrackPublishOptions defaultPublishOptions; const ConnectOptions({ diff --git a/lib/src/rtc_engine.dart b/lib/src/rtc_engine.dart index d1f9559..4ced892 100644 --- a/lib/src/rtc_engine.dart +++ b/lib/src/rtc_engine.dart @@ -137,6 +137,9 @@ class RTCEngine extends Disposable with EventsEmittable { required lk_models.TrackType kind, TrackDimension? dimension, }) async { + + // TODO: Check if cid already published + // send request to add track signalClient.sendAddTrack( cid: cid, name: name, type: kind, dimension: dimension); @@ -422,8 +425,8 @@ class RTCEngine extends Disposable with EventsEmittable { logger.fine('[$objectId] Disconnected $reason'); if (_reconnectAttempts >= _maxReconnectAttempts) { - logger.info( - '[$objectId] Could not connect after ${_reconnectAttempts} attempts, giving up'); + logger.info('[$objectId] Could not connect ' + 'after ${_reconnectAttempts} attempts, giving up'); await close(); events.emit(const EngineDisconnectedEvent()); return; diff --git a/lib/src/signal_client.dart b/lib/src/signal_client.dart index d9abdfc..d3e8692 100644 --- a/lib/src/signal_client.dart +++ b/lib/src/signal_client.dart @@ -121,13 +121,6 @@ class SignalClient extends Disposable with EventsEmittable { await _ws?.dispose(); } - // @override - // Future dispose() async { - // super.dispose(); - // await events.dispose(); - // await close(); - // } - void sendOffer(rtc.RTCSessionDescription offer) => _sendRequest(lk_rtc.SignalRequest( offer: offer.toSDKType(), diff --git a/lib/src/transport.dart b/lib/src/transport.dart index 44301d1..6eeb7ae 100644 --- a/lib/src/transport.dart +++ b/lib/src/transport.dart @@ -67,13 +67,6 @@ class PCTransport extends Disposable { wait: Timeouts.debounce, ); - // @override - // Future dispose() async { - // super.dispose(); - // // Ensure debounce won't fire - - // } - Future setRemoteDescription(rtc.RTCSessionDescription sd) async { if (isDisposed) { logger.warning('[$objectId] setRemoteDescription() already disposed');