Skip to content

Commit 4006a1a

Browse files
committed
more simulate scenarios
1 parent 7b66dc6 commit 4006a1a

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

Sources/LiveKit/Core/SignalClient.swift

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -636,16 +636,31 @@ internal extension SignalClient {
636636
func sendSimulate(scenario: SimulateScenario) -> Promise<Void> {
637637
log()
638638

639+
var shouldDisconnect = false
640+
639641
let r = Livekit_SignalRequest.with {
640642
$0.simulate = Livekit_SimulateScenario.with {
641-
if case .nodeFailure = scenario { $0.nodeFailure = true }
642-
if case .migration = scenario { $0.migration = true }
643-
if case .serverLeave = scenario { $0.serverLeave = true }
644-
if case .speakerUpdate(let secs) = scenario { $0.speakerUpdate = Int32(secs) }
643+
switch scenario {
644+
case .nodeFailure: $0.nodeFailure = true
645+
case .migration: $0.migration = true
646+
case .serverLeave: $0.serverLeave = true
647+
case .speakerUpdate(let secs): $0.speakerUpdate = Int32(secs)
648+
case .forceTCP:
649+
$0.switchCandidateProtocol = Livekit_CandidateProtocol.tcp
650+
shouldDisconnect = true
651+
case .forceTLS:
652+
$0.switchCandidateProtocol = Livekit_CandidateProtocol.tls
653+
shouldDisconnect = true
654+
}
645655
}
646656
}
647657

648-
return sendRequest(r)
658+
return sendRequest(r).then(on: queue) {
659+
if shouldDisconnect {
660+
let sdkError = NetworkError.disconnected(message: "Simulate scenario")
661+
self.cleanUp(reason: .networkError(sdkError))
662+
}
663+
}
649664
}
650665

651666
@discardableResult

Sources/LiveKit/Types/Other.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,6 @@ public enum SimulateScenario {
4444
case migration
4545
case serverLeave
4646
case speakerUpdate(seconds: Int)
47+
case forceTCP
48+
case forceTLS
4749
}

0 commit comments

Comments
 (0)