stasel / WebRTC-iOS

A simple native WebRTC demo iOS app using swift
Apache License 2.0
1.11k stars 241 forks source link

Q: is `localDataChannel` ever used? #126

Open Sajjon opened 1 year ago

Sajjon commented 1 year ago

Seems localDataChannel is initialized but never used?

stasel commented 1 year ago

Hi, Yes there is a usage of data channels in this demo app. It it used to send a message to the other peer via the UI. It is initialized together with the audio and video tracks in createMediaSenders()

Sajjon commented 1 year ago

@stasel Merry Christmas! Thanks your your prompt reply and thank you for WebRTC SPM package, it is great!

My question above was specifically about localDataChannel variable, it is private and it is initialized here, but it is never used.

The other "twin" channel remoteDataChannel is on the other hand used, here when sending data, it gets set when the callback peerConnection:didOpen is called here

I think it IS needed actually, but indeed "never used", it makes it so that the RTCOffer contains a DataChannel and it is needed as a "hook" for RTCDataChannelDelegate.

In my own code base I to not have the remoteDataCannel at all, I use the single one, i.e. I send data on the localDataChannel once it gets open.