Skip to content

Commit

Permalink
fix(lib): intercept all connection and publishing errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ThibaultBee committed Dec 12, 2023
1 parent 817b1d7 commit 9d0e9a9
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions Sources/ApiVideoLiveStream/ApiVideoLiveStream.swift
Original file line number Diff line number Diff line change
Expand Up @@ -403,22 +403,26 @@ public class ApiVideoLiveStream {
private func rtmpStatusHandler(_ notification: Notification) {
let e = Event.from(notification)
guard let data: ASObject = e.data as? ASObject,
let code: String = data["code"] as? String else
let code: String = data["code"] as? String,
let level: String = data["level"] as? String else
{
print("rtmpStatusHandler: failed to parse event: \(e)")
return
}
switch code {
case RTMPConnection.Code.connectSuccess.rawValue:
self.delegate?.connectionSuccess()
self.rtmpStream.publish(self.streamKey)

case RTMPConnection.Code.connectFailed.rawValue:
self.delegate?.connectionFailed(code)
case RTMPStream.Code.publishStart.rawValue:
self.delegate?.connectionSuccess()

case RTMPConnection.Code.connectClosed.rawValue:
self.delegate?.disconnection()

default:
if level == "error" {
self.delegate?.connectionFailed(code)
}
break
}
}
Expand Down

0 comments on commit 9d0e9a9

Please sign in to comment.