Add sid for reconnecting. (#168)
This commit is contained in:
@@ -71,6 +71,7 @@ class Engine extends Disposable with EventsEmittable<EngineEvent> {
|
||||
FastConnectOptions? fastConnectOptions;
|
||||
|
||||
bool _subscriberPrimary = false;
|
||||
String? _participantSid;
|
||||
|
||||
// server-provided ice servers
|
||||
List<lk_rtc.ICEServer> _serverProvidedIceServers = [];
|
||||
@@ -284,6 +285,7 @@ class Engine extends Disposable with EventsEmittable<EngineEvent> {
|
||||
connectOptions: connectOptions,
|
||||
roomOptions: roomOptions,
|
||||
reconnect: true,
|
||||
sid: _participantSid,
|
||||
);
|
||||
|
||||
if (publisher == null || subscriber == null) {
|
||||
@@ -593,6 +595,7 @@ class Engine extends Disposable with EventsEmittable<EngineEvent> {
|
||||
// create peer connections
|
||||
_subscriberPrimary = event.response.subscriberPrimary;
|
||||
_serverProvidedIceServers = event.response.iceServers;
|
||||
_participantSid = event.response.participant.sid;
|
||||
|
||||
logger.fine('onConnected subscriberPrimary: ${_subscriberPrimary}, '
|
||||
'serverVersion: ${event.response.serverVersion}, '
|
||||
|
||||
@@ -54,6 +54,7 @@ class SignalClient extends Disposable with EventsEmittable<SignalEvent> {
|
||||
required ConnectOptions connectOptions,
|
||||
required RoomOptions roomOptions,
|
||||
bool reconnect = false,
|
||||
String? sid,
|
||||
}) async {
|
||||
final rtcUri = await Utils.buildUri(
|
||||
uriString,
|
||||
@@ -61,6 +62,7 @@ class SignalClient extends Disposable with EventsEmittable<SignalEvent> {
|
||||
connectOptions: connectOptions,
|
||||
roomOptions: roomOptions,
|
||||
reconnect: reconnect,
|
||||
sid: sid,
|
||||
);
|
||||
|
||||
logger.fine('SignalClient connecting with url: $rtcUri');
|
||||
|
||||
@@ -146,6 +146,7 @@ class Utils {
|
||||
bool reconnect = false,
|
||||
bool validate = false,
|
||||
bool forceSecure = false,
|
||||
String? sid,
|
||||
}) async {
|
||||
final Uri uri = Uri.parse(uriString);
|
||||
|
||||
@@ -171,6 +172,7 @@ class Utils {
|
||||
'auto_subscribe': connectOptions.autoSubscribe ? '1' : '0',
|
||||
'adaptive_stream': roomOptions.adaptiveStream ? '1' : '0',
|
||||
if (reconnect) 'reconnect': '1',
|
||||
if (reconnect && sid != null) 'sid': sid,
|
||||
'protocol': connectOptions.protocolVersion.toStringValue(),
|
||||
'sdk': 'flutter',
|
||||
'version': LiveKitClient.version,
|
||||
|
||||
Reference in New Issue
Block a user