From e8195ddb756e37ccedaf60b3ffc8e4117b15aaae Mon Sep 17 00:00:00 2001 From: gbattistel Date: Wed, 8 Jan 2025 00:08:16 -0300 Subject: [PATCH] fix: add delay between debugReportStartMessage and the addConnectionMessage --- .../Telnyx/WebRTC/Stats/WebRTCStatsReporter.swift | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/TelnyxRTC/Telnyx/WebRTC/Stats/WebRTCStatsReporter.swift b/TelnyxRTC/Telnyx/WebRTC/Stats/WebRTCStatsReporter.swift index 5927545b..e3ee6b4e 100644 --- a/TelnyxRTC/Telnyx/WebRTC/Stats/WebRTCStatsReporter.swift +++ b/TelnyxRTC/Telnyx/WebRTC/Stats/WebRTCStatsReporter.swift @@ -13,16 +13,20 @@ class WebRTCStatsReporter { // MARK: - Initializer init(socket: Socket) { self.socket = socket - self.sendDebugReportStartMessage(id: self.reportId) } public func startDebugReport(peerId: UUID, peer: Peer) { + self.peerId = peerId self.peer = peer - self.sendAddConnectionMessage() + self.sendDebugReportStartMessage(id: self.reportId) + + let delay = DispatchTime.now() + 0.2 + DispatchQueue.main.asyncAfter(deadline: delay) { [weak self] in + self?.sendAddConnectionMessage() + } self.setupEventHandler() - let queue = DispatchQueue.main timer = DispatchSource.makeTimerSource(queue: queue) timer?.schedule(deadline: .now(), repeating: 2.0)