Re: Panic between createOffer() and setLocalDescription()

Callback hell from real code:


peerConnection.setRemoteDescription(offer, function()
{
  peerConnection.createAnswer(function(answer)
  {
    peerConnection.setLocalDescription(answer, function()
    {

        // Send back answer SDP

    },
    console.error);
  },
  console.error);
},
console.error);


I have just noticed this on the code I'm using. I was doing mostly a
copy&paste of this snippet between my projects since it was a "live
with it" issue, by since this discussion started I'm now seeing how
much disturbing the current API is. As you can see here, definitely
for the most basic cases not only the setLocalDescription() could be
integrated on createOffer(), but as you can see here for the most
common use cases also the trio of
setRemoteDescription-createAnswer-setLocalDescription could be merged
in just one function (createAnswer() giving the offer as first
parameter? a new one processOffer()?).

2014-02-20 10:44 GMT+01:00 piranna@gmail.com <piranna@gmail.com>:
>> I'm not sure that's a compelling reason to separate the two, but it's a
>> possible reason, even in the absence of SDP modification.
>>
> I'm not saying to remove setLocalDescription(), I'm only saying that
> for most use cases is redundant to call to
> createOffer()/createAnswer() and inmediately to setLocalDescription(),
> so I'll change the spec to do the call implicitly and if some changes
> are required, let the user to do the call explicitly, overwritting
> this way the content of the local description with its custom one.
> This will make easier to new comers what's the call flow:
>
> createOffer() -> send()
> onmessage -> setRemoteDescription()
> createAnswer() -> send()
> onmessage -> setRemoteDescription()
>
> Honestly, if you need to call to setLocalDescription() with a modified
> SDP, you are not in "WebRTC 101" anymore... Why complicate it?
>
>
> --
> "Si quieres viajar alrededor del mundo y ser invitado a hablar en un
> monton de sitios diferentes, simplemente escribe un sistema operativo
> Unix."
> - Linus Tordvals, creador del sistema operativo Linux



-- 
"Si quieres viajar alrededor del mundo y ser invitado a hablar en un
monton de sitios diferentes, simplemente escribe un sistema operativo
Unix."
- Linus Tordvals, creador del sistema operativo Linux

Received on Thursday, 20 February 2014 11:33:33 UTC