From 34e630b5bf528214a33329c551e0f7b881fffdab Mon Sep 17 00:00:00 2001 From: Niels Andriesse Date: Wed, 18 Aug 2021 09:06:06 +1000 Subject: [PATCH] Add documentation --- .../MessageReceiver+Handling.swift | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/SessionMessagingKit/Sending & Receiving/MessageReceiver+Handling.swift b/SessionMessagingKit/Sending & Receiving/MessageReceiver+Handling.swift index 403dc2d2c..0f856f255 100644 --- a/SessionMessagingKit/Sending & Receiving/MessageReceiver+Handling.swift +++ b/SessionMessagingKit/Sending & Receiving/MessageReceiver+Handling.swift @@ -256,21 +256,27 @@ extension MessageReceiver { // MARK: - Call Messages public static func handleCallMessage(_ message: CallMessage, using transaction: Any) { - let webRTCSession: WebRTCSession - if let current = WebRTCSession.current { - webRTCSession = current - } else { - WebRTCSession.current = WebRTCSession(for: message.sender!) - webRTCSession = WebRTCSession.current! + func getWebRTCSession() -> WebRTCSession { + let result: WebRTCSession + if let current = WebRTCSession.current { + result = current + } else { + WebRTCSession.current = WebRTCSession(for: message.sender!) + result = WebRTCSession.current! + } + return result } switch message.kind! { case .offer: print("[Calls] Received offer message.") + // Delegate to the main app, which is expected to show a dialog confirming + // that the user wants to pick up the call. When they do, the SDP contained + // in the offer message will be passed to WebRTCSession.handleRemoteSDP(_:from:). handleOfferCallMessage?(message) case .answer: print("[Calls] Received answer message.") let sdp = RTCSessionDescription(type: .answer, sdp: message.sdps![0]) - webRTCSession.handleRemoteSDP(sdp, from: message.sender!) + getWebRTCSession().handleRemoteSDP(sdp, from: message.sender!) case .provisionalAnswer: break // TODO: Implement case let .iceCandidates(sdpMLineIndexes, sdpMids): var candidates: [RTCIceCandidate] = [] @@ -282,7 +288,7 @@ extension MessageReceiver { let candidate = RTCIceCandidate(sdp: sdp, sdpMLineIndex: Int32(sdpMLineIndex), sdpMid: sdpMid) candidates.append(candidate) } - webRTCSession.handleICECandidates(candidates) + getWebRTCSession().handleICECandidates(candidates) } }