Skip to content

Commit

Permalink
trickle-ice case modified for url structure test when iceserver creat…
Browse files Browse the repository at this point in the history
…ion and extra file delected
  • Loading branch information
Lewis authored and Lewis committed Jan 27, 2015
1 parent aa2fe4d commit b8e0c3b
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 94 deletions.
7 changes: 4 additions & 3 deletions samples/web/content/peerconnection/trickle-ice/index.html
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ <h1><a href="https://plugin.temasys.com.sg/demo/index.html" title="WebRTC sample
<h2>ICE servers</h2>

<select id="servers" size="4">
<option value="{&quot;url&quot;:&quot;stun:stun.l.google.com:19302&quot;}">stun:stun.l.google.com:19302</option>
<option value="{&quot;url&quot;:&quot;stun:stun.l.google.com:19302&quot;,&quot;hasCredentials&quot;:false}">stun:stun.l.google.com:19302</option>

This comment has been minimized.

Copy link
@johache

johache Jan 27, 2015

I believe hasCredentials is automatically set from the Adapter and it should not be set here

<option value="{&quot;url&quot;:[&quot;stun:stun.voxgratia.org&quot;,&quot;stun:stunserver.org&quot;],&quot;hasCredentials&quot;:false}">[stun:stun.voxgratia.org ; stun:stunserver.org]</option>

This comment has been minimized.

Copy link
@johache

johache Jan 27, 2015

same

<option value="{&quot;url&quot;:&quot;stun:stun.callwithus.com&quot;,&quot;hasCredentials&quot;:false}">stun:stun.callwithus.com</option>

This comment has been minimized.

Copy link
@johache

johache Jan 27, 2015

same

</select>

<div>
<label for="url">STUN or TURN URI:</label>
<input id="url">
Expand All @@ -58,6 +59,7 @@ <h2>ICE servers</h2>
<div>
<button id="add">Add Server</button>
<button id="remove">Remove Server</button>
<button id="changeStruct">Change url structure</button>
</div>

</section>
Expand Down Expand Up @@ -110,7 +112,6 @@ <h2>ICE options</h2>

<script src="https://cdn.temasys.com.sg/adapterjs/0.10.x/adapter.debug.js"></script>
<script src="js/main.js"></script>

<script src="../../../js/lib/ga.js"></script>
</body>
</html>
37 changes: 33 additions & 4 deletions samples/web/content/peerconnection/trickle-ice/js/main.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,45 @@ var candidateTBody = document.getElementById('candidatesBody');
var gatherButton = document.getElementById('gather');
var passwordInput = document.getElementById('password');
var removeButton = document.getElementById('remove');
var changeButton = document.getElementById('changeStruct');
var servers = document.getElementById('servers');
var urlInput = document.getElementById('url');
var usernameInput = document.getElementById('username');
var ipv6Check = document.getElementById('ipv6');
var unbundleCheck = document.getElementById('unbundle');
var output = document.getElementById('output');


addButton.onclick = addServer;
gatherButton.onclick = start;
removeButton.onclick = removeServer;
changeButton.onclick = changeStruct;

var begin, pc;

var changed = false;

This comment has been minimized.

Copy link
@johache

johache Jan 27, 2015

Could you change this variable name for something clearer? like `arrayStruct``or something?


function changeStruct(){
if(!changed){
for(var i = servers.options.length - 1; i>=0; --i) {
var sers = JSON.parse(servers[i].value);
if(typeof sers.url === "string"){
servers[i].value = servers[i].value.replace("\":\"", "\":[\"");
servers[i].value = servers[i].value.replace("\",", "\"],");
servers[i].text = '[' + servers[i].text + ']';
}
}
changed = !changed;
}else{
for(var i = servers.options.length - 1; i>=0; --i) {
var sers = JSON.parse(servers[i].value);
if(sers.url.length === 1 ){
servers[i].value = servers[i].value.replace("\":[\"", "\":\"");
servers[i].value = servers[i].value.replace("\"],", "\",");
servers[i].text = servers[i].text.substr(1, servers[i].text.length - 2);
}
}
changed = !changed;
}
}
function addServer() {
var scheme = urlInput.value.split(':')[0];
if (scheme !== 'stun' && scheme !== 'turn' && scheme !== 'turns') {
Expand All @@ -35,7 +60,11 @@ function addServer() {
var option = document.createElement('option');
var iceServer = createIceServer(urlInput.value, usernameInput.value, passwordInput.value);
option.value = JSON.stringify(iceServer);
option.text = urlInput.value + ' ';
if(changed){
option.text = '[' + urlInput.value + '] ';
}else{
option.text = urlInput.value + ' ';
}
var username = usernameInput.value;
var password = passwordInput.value;
if (username || password) {
Expand Down Expand Up @@ -78,7 +107,7 @@ function start() {
// Create a PeerConnection with no streams, but force a m=audio line.
// This will gather candidates for either 1 or 2 ICE components, depending
// on whether the unbundle RTCP checkbox is checked.
var config = {"iceServers": iceServers };
var config = {"iceServers":iceServers};
var pcConstraints = {"mandatory": {"IceTransports": iceTransports}};
var offerConstraints = {"mandatory": {"OfferToReceiveAudio": true}};
// Whether we gather IPv6 candidates.
Expand Down
87 changes: 0 additions & 87 deletions samples/web/content/trickle-ice/js/main.js

This file was deleted.

0 comments on commit b8e0c3b

Please sign in to comment.