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

[ACTION-49] DataChannel issues

From: Randell Jesup <randell-ietf@jesup.org>
Date: Tue, 26 Jun 2012 18:04:43 -0400
Message-ID: <4FEA31FB.6010707@jesup.org>
To: public-webrtc@w3.org
CC: Michael Tuexen <tuexen@fh-muenster.de>
On 6/26/2012 5:18 AM, Stefan Hakansson LK wrote:
> Adding a DataChannel object [ACTION-49]
>      Proposal written up by Randell
>      Not clear what the benefits of introducing it is

Options follow.  I prefer option #3 (with default channels in SDP, but 
I'm also ok with them being held internally for creation on connection).
Note all of these assume the decision made in Stockholm, which was to 
mirror the WebSockets API (channels must wait on onopen before you call 
send()).

The connection object's main advantage is being able to ask it directly 
for global stats, etc, instead of having those be methods on 
PeerConnection - and if for any reason we want to enable DataChannels 
via something other than PeerConnection, you'd have a discrete 
object/interface already defined for it; or you could allow two data 
connections (associations) per PeerConnection (though there are very 
limited reasons I can see why).

I think "keep it simple, optimize only the common cases" is the right 
tack.  Option #3, with the only optimization being to allow default 
channels in the SDP because that's a very common case.

#1. Minimal internal state, use onopen for adding initial channels:

        connection = pc.createDataConnection(default_streams,...);
        connection.onopen = connection_onopen;
        ...
        pc.createOffer()/createAnswer();
        ...

        function connection_onopen() {
           channel_1  = connection.createDataChannel(....);
           channel_1.onopen = chan_1_connected;
           channel_1.onmessage = chan_1_messages;
        }

        function chan_1_connected() {
           channel_1.send("foo");
        }
        etc
        ...
        connection.increaseMaxChannelsTo = 1234; // not really needed
        ...
        connection.close();

#2. Connection object, early channel creation -
     Good for static channels; can add channels later.

        connection = pc.createDataConnection(default_streams,...);
        connection.onopen = connection_onopen; // optional
        channel_1 = connection.createDataChannel(....);
        channel_1.onopen = chan_1_connected;
        channel_1.onmessage = chan_1_messages;
        ...
        pc.createOffer()/createAnswer(); // SDP includes channels
        ...

        function chan_1_connected() {
           channel_1.send("foo");
        }
        etc
        ...
        connection.increaseMaxChannelsTo = 1234; // not really needed
        ...
        connection.close();  // disconnects all DataChannels

#3. No connection object, early channel creation -
     Good for static channels; can add channels later.


        pc.addDataChannel(default_streams,...);
        channel_1 = pc.createDataChannel(....);
        channel_1.onopen = chan_1_connected;
        channel_1.onmessage = chan_1_messages;
        ...
        pc.createOffer()/createAnswer(); // SDP includes channels
        // OR the channels are started automatically once the
        // connection/association is live
        ...

        function chan_1_connected() {
           channel_1.send("foo");
        }
        etc
        ...
        // Don't let user bump channels by hand, leave to automatic
        ...
        pc.closeAllDataChannels();  // disconnects all DataChannels

#4. No connection object, no early channel creation -
     All channels added after pc is connected.

        pc.addDataChannel(default_streams);
        ...
        pc.createOffer()/createAnswer(); // SDP just has data connection
        ...

        function on_pc_connected() {
           channel_1 = pc.createDataChannel(....);
           channel_1.onopen = chan_1_connected;
           channel_1.onmessage = chan_1_messages;
        }

        function chan_1_connected() {
           channel_1.send("foo");
        }
        etc
        ...
        // Don't let user bump channels by hand, leave to automatic
        ...
        pc.closeAllDataChannels();  // disconnects all DataChannels


-- 
Randell Jesup
randell-ietf@jesup.org
Received on Tuesday, 26 June 2012 22:05:53 UTC

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