Skip to content

Commit

Permalink
async: Engine.sendSyncState
Browse files Browse the repository at this point in the history
  • Loading branch information
hiroshihorie committed Oct 31, 2023
1 parent e399562 commit 00e4947
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions Sources/LiveKit/Core/Engine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ internal extension Engine {
return promise(from: self.primaryTransportConnectedCompleter.wait)
}.then(on: queue) { _ in
// send SyncState before offer
self.sendSyncState()
promise(from: self.sendSyncState)
}.then(on: queue) { () -> Promise<Void> in

self.subscriber?.restartingIce = true
Expand Down Expand Up @@ -547,18 +547,18 @@ internal extension Engine {

internal extension Engine {

func sendSyncState() -> Promise<Void> {
func sendSyncState() async throws {

guard let room = room else {
// this should never happen
log("Room is nil", .error)
return Promise(())
return
}

guard let subscriber = subscriber,
let previousAnswer = subscriber.localDescription else {
// No-op
return Promise(())
return
}

let previousOffer = subscriber.remoteDescription
Expand All @@ -583,12 +583,10 @@ internal extension Engine {
$0.subscribe = !autoSubscribe
}

return promise(from: signalClient.sendSyncState,
param1: previousAnswer.toPBType(),
param2: previousOffer?.toPBType(),
param3: subscription,
param4: room._state.localParticipant?.publishedTracksInfo(),
param5: publisherDC.infos())
try await signalClient.sendSyncState(answer: previousAnswer.toPBType(),
offer: previousOffer?.toPBType(),
subscription: subscription, publishTracks: room._state.localParticipant?.publishedTracksInfo(),
dataChannels: publisherDC.infos())
}
}

Expand Down

0 comments on commit 00e4947

Please sign in to comment.