Re: Data API symmetry

This line from case B #2 made me have an opinion.

On 04/25/2012 04:04 PM, Adam Bergkvist wrote:
>
>
>     viaWebServer.send("setup extra channel");


I am not happy with interfaces that necessitate going through the server 
to set up channels.

So I think I like the "ondatachannel" approach better.

I *think* this can be written differently, to emphasize the symmetry a 
little bit more, in the case where both sides get an "open" event:

Case A #1:

peerConn.onopen = function () {
     if (caller) {
         chatDataChan = peerConn.createDataChannel("chat", chatSettings);
         chatDataChan.onopen = startChat;
         chatDataChan.onmessage = showChatMessage;

         extraDataChan = peerConn.createDataChannel("extra", 
extraSettings);
         extraDataChan.onopen = startExtra;
         extraDataChan.onmessage = onExtraMessage;
     }

     peerConn.ondatachannel = function (evt) {

         var chan = evt.channel;
         if (chan.label == "chat") {
             chatDataChan = chan;
             chatDataChan.onopen = startChat;
             chatDataChan.onmessage = showChatMessage;
         }
         else {
             extraDataChan = chan;
             extraDataChan.onopen = startExtra;
             extraDataChan.onmessage = onExtraMessage;
         }
     };
};





          Harald

Received on Wednesday, 25 April 2012 15:22:04 UTC