Skip to content

Commit

Permalink
Add participant sid when resume (#478)
Browse files Browse the repository at this point in the history
  • Loading branch information
hiroshihorie authored Sep 6, 2024
1 parent 491a4e8 commit 9f2c180
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions Sources/LiveKit/Core/Room+Engine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ extension Room {
token,
connectOptions: _state.connectOptions,
reconnectMode: _state.isReconnectingWithMode,
participantSid: localParticipant.sid,
adaptiveStream: _state.roomOptions.adaptiveStream)
try Task.checkCancellation()

Expand Down
3 changes: 3 additions & 0 deletions Sources/LiveKit/Core/SignalClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ actor SignalClient: Loggable {
_ token: String,
connectOptions: ConnectOptions? = nil,
reconnectMode: ReconnectMode? = nil,
participantSid: Participant.Sid? = nil,
adaptiveStream: Bool) async throws -> ConnectResponse
{
await cleanUp()
Expand All @@ -126,6 +127,7 @@ actor SignalClient: Loggable {
token,
connectOptions: connectOptions,
reconnectMode: reconnectMode,
participantSid: participantSid,
adaptiveStream: adaptiveStream)

if reconnectMode != nil {
Expand Down Expand Up @@ -179,6 +181,7 @@ actor SignalClient: Loggable {
let validateUrl = try Utils.buildUrl(url,
token,
connectOptions: connectOptions,
participantSid: participantSid,
adaptiveStream: adaptiveStream,
validate: true)

Expand Down
9 changes: 8 additions & 1 deletion Sources/LiveKit/Support/Utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ class Utils {
_ token: String,
connectOptions: ConnectOptions? = nil,
reconnectMode: ReconnectMode? = nil,
participantSid: Participant.Sid? = nil,
adaptiveStream: Bool,
validate: Bool = false,
forceSecure: Bool = false
Expand Down Expand Up @@ -198,7 +199,13 @@ class Utils {
}

// only for quick-reconnect
queryItems.append(URLQueryItem(name: "reconnect", value: reconnectMode == .quick ? "1" : "0"))
if reconnectMode == .quick {
queryItems.append(URLQueryItem(name: "reconnect", value: "1"))
if let sid = participantSid {
queryItems.append(URLQueryItem(name: "sid", value: sid.stringValue))
}
}

queryItems.append(URLQueryItem(name: "auto_subscribe", value: connectOptions.autoSubscribe ? "1" : "0"))
queryItems.append(URLQueryItem(name: "adaptive_stream", value: adaptiveStream ? "1" : "0"))

Expand Down

0 comments on commit 9f2c180

Please sign in to comment.