This commit is contained in:
Hiroshi Horie
2021-10-20 21:16:13 +09:00
parent 9366db0dde
commit 666380d39b
6 changed files with 21 additions and 30 deletions
+8 -5
View File
@@ -39,6 +39,7 @@ class _ConnectPageState extends State<ConnectPage> {
super.dispose();
}
// Read saved URL and Token
Future<void> _readPrefs() async {
final prefs = await SharedPreferences.getInstance();
_uriCtrl.text = prefs.getString(_storeKeyUri) ?? '';
@@ -48,6 +49,7 @@ class _ConnectPageState extends State<ConnectPage> {
});
}
// Save URL and Token
Future<void> _writePrefs() async {
final prefs = await SharedPreferences.getInstance();
await prefs.setString(_storeKeyUri, _uriCtrl.text);
@@ -62,12 +64,14 @@ class _ConnectPageState extends State<ConnectPage> {
_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<ConnectPage> {
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<ConnectPage> {
setState(() {
_simulcast = value;
});
// await _writePrefs();
}
@override
+5 -9
View File
@@ -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;
+3
View File
@@ -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({
+5 -2
View File
@@ -137,6 +137,9 @@ class RTCEngine extends Disposable with EventsEmittable<EngineEvent> {
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<EngineEvent> {
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;
-7
View File
@@ -121,13 +121,6 @@ class SignalClient extends Disposable with EventsEmittable<SignalEvent> {
await _ws?.dispose();
}
// @override
// Future<void> dispose() async {
// super.dispose();
// await events.dispose();
// await close();
// }
void sendOffer(rtc.RTCSessionDescription offer) =>
_sendRequest(lk_rtc.SignalRequest(
offer: offer.toSDKType(),
-7
View File
@@ -67,13 +67,6 @@ class PCTransport extends Disposable {
wait: Timeouts.debounce,
);
// @override
// Future<void> dispose() async {
// super.dispose();
// // Ensure debounce won't fire
// }
Future<void> setRemoteDescription(rtc.RTCSessionDescription sd) async {
if (isDisposed) {
logger.warning('[$objectId] setRemoteDescription() already disposed');