protocol 8. (#134)
* protocol 8. * add FastConnectOptions. * update. * fix. * Deprecated the top connect method. * Add fast connect button in example. * Create a Listener before connecting. * Force protocol-v7 for deprecated APIs. * remove commented out line. * relative path import. * update.
This commit is contained in:
@@ -64,6 +64,7 @@ class Engine extends Disposable with EventsEmittable<EngineEvent> {
|
||||
|
||||
ConnectOptions connectOptions;
|
||||
RoomOptions roomOptions;
|
||||
FastConnectOptions? fastConnectOptions;
|
||||
|
||||
bool _subscriberPrimary = false;
|
||||
|
||||
@@ -100,12 +101,14 @@ class Engine extends Disposable with EventsEmittable<EngineEvent> {
|
||||
String token, {
|
||||
ConnectOptions? connectOptions,
|
||||
RoomOptions? roomOptions,
|
||||
FastConnectOptions? fastConnectOptions,
|
||||
}) async {
|
||||
this.url = url;
|
||||
this.token = token;
|
||||
// update new options (if exists)
|
||||
this.connectOptions = connectOptions ?? this.connectOptions;
|
||||
this.roomOptions = roomOptions ?? this.roomOptions;
|
||||
this.fastConnectOptions = fastConnectOptions;
|
||||
|
||||
_updateConnectionState(ConnectionState.connecting);
|
||||
|
||||
|
||||
@@ -14,6 +14,8 @@ import '../participant/remote.dart';
|
||||
import '../proto/livekit_models.pb.dart' as lk_models;
|
||||
import '../proto/livekit_rtc.pb.dart' as lk_rtc;
|
||||
import '../support/disposable.dart';
|
||||
import '../track/local/audio.dart';
|
||||
import '../track/local/video.dart';
|
||||
import '../track/track.dart';
|
||||
import '../types/other.dart';
|
||||
import 'engine.dart';
|
||||
@@ -117,12 +119,14 @@ class Room extends DisposableChangeNotifier with EventsEmittable<RoomEvent> {
|
||||
String token, {
|
||||
ConnectOptions? connectOptions,
|
||||
RoomOptions? roomOptions,
|
||||
FastConnectOptions? fastConnectOptions,
|
||||
}) =>
|
||||
engine.connect(
|
||||
url,
|
||||
token,
|
||||
connectOptions: connectOptions,
|
||||
roomOptions: roomOptions,
|
||||
fastConnectOptions: fastConnectOptions,
|
||||
);
|
||||
|
||||
void _setUpSignalListeners() => _signalListener
|
||||
@@ -141,6 +145,32 @@ class Room extends DisposableChangeNotifier with EventsEmittable<RoomEvent> {
|
||||
info: event.response.participant,
|
||||
);
|
||||
|
||||
if (connectOptions.protocolVersion.index >= ProtocolVersion.v8.index &&
|
||||
engine.fastConnectOptions != null) {
|
||||
var options = engine.fastConnectOptions!;
|
||||
|
||||
var audio = options.microphone;
|
||||
if (audio.enabled != null && audio.enabled == true) {
|
||||
_localParticipant!.setMicrophoneEnabled(true);
|
||||
} else if (audio.track != null) {
|
||||
_localParticipant!.publishAudioTrack(audio.track as LocalAudioTrack);
|
||||
}
|
||||
|
||||
var video = options.camera;
|
||||
if (video.enabled != null && video.enabled == true) {
|
||||
_localParticipant!.setCameraEnabled(true);
|
||||
} else if (video.track != null) {
|
||||
_localParticipant!.publishVideoTrack(video.track as LocalVideoTrack);
|
||||
}
|
||||
|
||||
var screen = options.screen;
|
||||
if (screen.enabled != null && screen.enabled == true) {
|
||||
_localParticipant!.setScreenShareEnabled(true);
|
||||
} else if (screen.track != null) {
|
||||
_localParticipant!.publishVideoTrack(screen.track as LocalVideoTrack);
|
||||
}
|
||||
}
|
||||
|
||||
for (final info in event.response.otherParticipants) {
|
||||
logger.fine('Creating RemoteParticipant: ${info.sid}(${info.identity}) '
|
||||
'tracks:${info.tracks.map((e) => e.sid)}');
|
||||
|
||||
Reference in New Issue
Block a user