W3C home > Mailing lists > Public > public-webrtc@w3.org > June 2012

Re: Suggestion: Less verbose syntax for offer/answer handling

From: Eric Rescorla <ekr@rtfm.com>
Date: Tue, 5 Jun 2012 08:08:55 -0700
Message-ID: <CABcZeBMU43p65qxSQLiintiP1dgv9Q57epE5wmtPJzyMZqjbwQ@mail.gmail.com>
To: Adam Bergkvist <adam.bergkvist@ericsson.com>
Cc: "public-webrtc@w3.org" <public-webrtc@w3.org>
I'm pretty indifferent to these options, but is there any other
advantage to this
other than JS compactness?

-Ekr


On Tue, Jun 5, 2012 at 6:58 AM, Adam Bergkvist
<adam.bergkvist@ericsson.com> wrote:
> Hi
>
> This suggestion uses the SdpType attribute of SessionDescription (discussed
> in:
> http://lists.w3.org/Archives/Public/public-webrtc/2012May/0047.html) to
> include type information in the SessionDescription object. By doing so, we
> can have a less verbose syntax where the JavaScript developer can work with
> self-contained objects that are generated and understood by PeerConnection.
>
> This doesn't reduce flexibility since the application can reset the type of,
> e.g., an "answer" to an "pranswer" to make PeerConnection interpret it as
> such.
>
> Example of creating an offer:
>
> --- Current syntax:
>
> pc.createOffer(function (offer) {
>    pc.setLocalDescription("offer", offer);
>    sendMessage(JSON.stringify({ "type": "offer", "sdp": offer }));
> });
>
> --- Less verbose syntax:
>
> pc.createOffer(function (offer) {
>    pc.updateLocalDescription(offer);
>    sendMessage(offer);
> });
>
> Example of handling an incoming signaling message:
>
> --- Current syntax:
>
> signalingChannel.onmessage = function (evt) {
>    var msg = JSON.parse(evt.data);
>    switch (msg.type) {
>    case "offer":
>        createPeerConnection();
>        pc.setRemoteDescription(msg.type,
>                                new SessionDescription(msg.sdp));
>        break;
>    case "answer":
>    case "pranswer":
>        pc.setRemoteDescription(msg.type,
>                                new SessionDescription(msg.sdp));
>        break;
>    case "candidate":
>        pc.addIceCandidate(new IceCandidate(msg.sdp));
>        break;
>    }
> };
>
> --- Less verbose syntax:
>
> signalingChannel.onmessage = function (evt) {
>    if (!pc)
>        createPeerConnection();
>
>    pc.updateRemoteDescription(evt.data);
> };
>
> /Adam
>
Received on Tuesday, 5 June 2012 15:18:00 UTC

This archive was generated by hypermail 2.3.1 : Monday, 23 October 2017 15:19:28 UTC