Skip to content

Commit

Permalink
make DataChannelPair.close sync
Browse files Browse the repository at this point in the history
  • Loading branch information
hiroshihorie committed Oct 30, 2023
1 parent c1cd410 commit b9bb1da
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Sources/LiveKit/Core/DataChannelPair.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ internal class DataChannelPair: NSObject, Loggable {
}
}

public func close() -> Promise<Void> {
public func close() {

let reliable = _reliableChannel
let lossy = _lossyChannel
Expand All @@ -85,7 +85,7 @@ internal class DataChannelPair: NSObject, Loggable {
openCompleter = Promise<Void>.pending()

// execute on .webRTC queue
return Promise(on: .liveKitWebRTC) {
DispatchQueue.liveKitWebRTC.sync {
reliable?.close()
lossy?.close()
}
Expand Down
14 changes: 4 additions & 10 deletions Sources/LiveKit/Core/Engine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -181,18 +181,12 @@ internal class Engine: MulticastDelegate<EngineDelegate> {
// Resets state of transports
func cleanUpRTC() -> Promise<Void> {

Promise<Void>(on: queue) { [weak self] () -> Promise<Void> in
Promise<Void>(on: queue) { [weak self] in

// close data channels

guard let self = self else { return Promise(()) }

let closeDataChannelPromises = [
self.publisherDC.close(),
self.subscriberDC.close()
]

return closeDataChannelPromises.all(on: self.queue)
guard let self = self else { return }
self.publisherDC.close()
self.subscriberDC.close()

}.then(on: queue) { [weak self] () -> Promise<Void> in

Expand Down

0 comments on commit b9bb1da

Please sign in to comment.