Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

when initiator can send message via DataChannel. Example 22 #240

Closed
Jxck opened this issue Sep 15, 2015 · 5 comments
Closed

when initiator can send message via DataChannel. Example 22 #240

Jxck opened this issue Sep 15, 2015 · 5 comments

Comments

@Jxck
Copy link
Contributor

Jxck commented Sep 15, 2015

in 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 ?
}

I think it's better to send message after channel has connected.

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 ?
  });
}

is that correct ?
or receive RTCDataChannel from ondatachannel event in initiate too ?

@robin-raymond
Copy link
Contributor

FYI - you can construct the DataChannel before SctpTransport.start is called. Data sent before start is called should be buffered until SctpTransport is started and underlying dtls is established.

@robin-raymond
Copy link
Contributor

Report party received ondatachannel event if params.negotiated = false.

@aboba
Copy link
Contributor

aboba commented Sep 18, 2015

I will add a comment to make it clear that data cannot be sent until sctp.start() is called.

@robin-raymond
Copy link
Contributor

In webrtc 1.0 is says If channel's readyState attribute is connecting, throw an InvalidStateError exception and abort these steps..

@aboba
Copy link
Contributor

aboba commented Sep 21, 2015

As a clarification, proposal is to add the following text (contained in WebRTC 1.0 Section 6.2.3) to the ORTC specification 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:

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

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

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

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.

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.

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.

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.

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

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.

robin-raymond pushed a commit that referenced this issue Oct 6, 2015
#240

- Fixed typos in Example 11, as noted in:
#241
#248

- Added text relating to RTCDataChannel exceptions and errors, as noted in:
#242

- Reconciliation of RTCRtpEncodingParameters dictionary with WebRTC 1.0, as noted in:
#249
@aboba aboba closed this as completed Oct 6, 2015
Jxck pushed a commit to Jxck/ortc that referenced this issue Oct 15, 2015
w3c#240

- Fixed typos in Example 11, as noted in:
w3c#241
w3c#248

- Added text relating to RTCDataChannel exceptions and errors, as noted in:
w3c#242

- Reconciliation of RTCRtpEncodingParameters dictionary with WebRTC 1.0, as noted in:
w3c#249
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants