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