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

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