Issue 240: when initiator can send message via DataChannel (Example 22)

n Example 22
in initiate(), sends message to channel before received remote sctp capabilities.
function initiate(signaller) {
  // snip...

  signaller.sendInitiate({
    // ... include ICE/DTLS info from other example.
    "sctpCapabilities": RTCSctpTransport.getCapabilities()
  }, function(remote) {
    sctp.start(remote.sctpCapabilities);
  });

  var channel = new RTCDataChannel(sctp, parameters);
  channel.send("foo"); // in this state, channel doesn't connected isn't it ?
}

Looking at WebRTC 1.0, it does appear that channel.send("foo") should throw an exception if channel.readyState is

Proposed resolution is to move the last two lines up after sctp.start(), as well as to add the following clarifying text to Section 11.3.2:


The send() method is overloaded to handle different data argument types. When any version of the method is called, the user agent must run the following steps:

1.   Let channel be the RTCDataChannel object on which data is to be sent.

2.   If channel.readyState attribute is connecting, throw an InvalidStateError exception and abort these steps.

3.   Execute the sub step that corresponds to the type of the methods argument:

o    string object:

Let data be the result of converting the argument object to a sequence of Unicode characters and increase the bufferedAmount attribute by the number of bytes needed to express data as UTF-8.

o    Blob object:

Let data be the raw data represented by the Blob object and increase the bufferedAmount attribute by the size of data, in bytes.

o    ArrayBuffer object:

Let data be the data stored in the buffer described by the ArrayBuffer object and increase the bufferedAmount attribute by the length of the ArrayBuffer in bytes.

o    ArrayBufferView object:

Let data be the data stored in the section of the buffer described by the ArrayBuffer object that the ArrayBufferView object references and increase the bufferedAmount attribute by the length of the ArrayBufferView in bytes.

4.   If channel's underlying data transport is not established yet, or if the closing procedure has started, then abort these steps.

5.   Attempt to send data on channel's underlying data transport; if the data cannot be sent, e.g. because it would need to be buffered but the buffer is full, the user agent must abruptly close channel's underlying data transport with an error.

Received on Tuesday, 22 September 2015 15:53:31 UTC