Skip to content

Wrong usage of RTCIceGatherOptions dictionaries on examples #464

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

Closed
murillo128 opened this issue Apr 13, 2016 · 1 comment
Closed

Wrong usage of RTCIceGatherOptions dictionaries on examples #464

murillo128 opened this issue Apr 13, 2016 · 1 comment

Comments

@murillo128
Copy link

Accroding to WebIDL definition, directories are asociative array data type with a fixed, ordered set of key–value pairs (https://www.w3.org/TR/WebIDL/#idl-dictionaries). The don't have a constructor, so in javascript a normal object mus be used when creating a dictionary.

But in several examples, for example, the RTCIceGatherOptions is created via a constructor (which is wrong).

// Create ICE gather options
var gatherOptions = new RTCIceGatherOptions();
gatherOptions.gatherPolicy = RTCIceGatherPolicy.relay;
gatherOptions.iceServers = [
  { urls: "stun:stun1.example.net" },
  { urls: "turn:turn.example.org", username: "user", credential: "myPassword", credentialType: "password" }
];

It sould be

// Create ICE gather options
var gatherOptions = {};
gatherOptions.gatherPolicy = RTCIceGatherPolicy.relay;
gatherOptions.iceServers = [
  { urls: "stun:stun1.example.net" },
  { urls: "turn:turn.example.org", username: "user", credential: "myPassword", credentialType: "password" }
];

or even better:

// Create ICE gather options
var gatherOptions = {
  gatherPolicy : RTCIceGatherPolicy.relay,
  gatherOptions.iceServers : [
    { urls: "stun:stun1.example.net" },
    { urls: "turn:turn.example.org", username: "user", credential: "myPassword", credentialType: "password" }
  ]
};
@robin-raymond
Copy link
Contributor

Correct, this needs to be fixed. Dictionaries are basically associative arrays and do not have constructors. Other languages without associative arrays like JS would be have more "fixed" definitions and possibly constructors, but not JS

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