@@ -26,6 +26,7 @@ class ViewController: UIViewController {
2626 // Nabto Signaling
2727 var signalingClient : SignalingClient ? = nil
2828 var messageTransport : MessageTransport ? = nil
29+ var signalingEventHandler : SignalingEventHandler ? = nil
2930 let signer = JWTMessageSigner ( sharedSecret: sharedSecret, keyId: " default " )
3031
3132 func initPeerConnectionFactory( ) {
@@ -93,7 +94,7 @@ class ViewController: UIViewController {
9394 container. layoutIfNeeded ( )
9495 }
9596
96- private func setupPeerConnection( _ iceServers: [ SignalingIceServer ] ) {
97+ private func setupPeerConnection( _ iceServers: [ SignalingIceServer ] ) async {
9798 let constraints = RTCMediaConstraints ( mandatoryConstraints: nil , optionalConstraints: nil )
9899 let config = RTCConfiguration ( )
99100 config. iceServers = iceServers. map { iceServer in
@@ -106,6 +107,8 @@ class ViewController: UIViewController {
106107
107108 peerConnection = factory. peerConnection ( with: config, constraints: constraints, delegate: self )
108109 perfectNegotiation = PerfectNegotiation ( peerConnection: peerConnection, messageTransport: messageTransport!)
110+ signalingEventHandler = SignalingEventHandler ( peerConnection: peerConnection, client: signalingClient!)
111+ await signalingClient? . addObserver ( signalingEventHandler!)
109112 }
110113}
111114
@@ -119,7 +122,7 @@ extension ViewController: MessageTransportObserver {
119122 }
120123
121124 func messageTransport( _ transport: any MessageTransport , didFinishSetup iceServers: [ SignalingIceServer ] ) async {
122- setupPeerConnection ( iceServers)
125+ await setupPeerConnection ( iceServers)
123126 }
124127}
125128
0 commit comments