Skip to content

Commit

Permalink
WS URI parameter in 'tryit' demo does set the 'outbound_proxy_set' pa…
Browse files Browse the repository at this point in the history
…rameter for the UA. It was ignored before and hardcoded to 'tryit.jssip.net'
  • Loading branch information
jmillan committed Oct 2, 2012
1 parent b0b73fe commit ea0b054
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 5 deletions.
2 changes: 1 addition & 1 deletion demos/tryit/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<div class="identification">
<input id="sip_uri" class="first unset" type="text" value="SIP uri (i.e: bob@biloxi.com)"/>
<input id="sip_password" class="unset" type="password" value="SIP password"/>
<input id="ws_uri" class="last unset" type="text" value="WS URI (i.e: wss://example.net)"/>
<input id="ws_uri" class="last unset" type="text" value="WS URI (i.e: ws://example.net:10080)"/>
</div>
</div>

Expand Down
49 changes: 45 additions & 4 deletions demos/tryit/js/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ $(document).ready(function(){
// Default settings.
var default_sip_uri = "jmillan@jssip.net";
var default_sip_password = '';
var outbound_proxy_set = [{
var outbound_proxy_set = {
host: "tryit.jssip.net:10080",
ws_path:'ws',
ws_query: 'wwdf'
}];
};


// Global variables.
Expand Down Expand Up @@ -94,8 +94,15 @@ $(document).ready(function(){
sip_uri = login_sip_uri.val();
if (login_sip_password.val() != "" && ! login_sip_password.hasClass("unset"))
sip_password = login_sip_password.val();
if (login_ws_uri.val() != "" && ! login_ws_uri.hasClass("unset"))
if (login_ws_uri.val() != "" && ! login_ws_uri.hasClass("unset")) {
ws_uri = login_ws_uri.val();
if (!check_ws_uri(ws_uri)) {
alert("Invalid WS URI field");
return;
} else {
outbound_proxy_set = check_ws_uri(ws_uri);
}
}

if (sip_uri == null) {
alert("Please fill SIP uri field");
Expand Down Expand Up @@ -209,7 +216,7 @@ $(document).ready(function(){
});

var configuration = {
'outbound_proxy_set': outbound_proxy_set,
'outbound_proxy_set': [outbound_proxy_set],
'uri': sip_uri,
'display_name': '',
'password': sip_password,
Expand Down Expand Up @@ -290,6 +297,40 @@ $(document).ready(function(){
return get_octet()+'.'+get_octet()+'.'+get_octet()+'.'+get_octet();
}

function check_ws_uri(ws_uri) {
var ws_uri_prefix, ws_uri_hostport, ws_uri_path, ws_uri_query, slash_idx, query_idx;

ws_uri_prefix = ws_uri.substr(0,5);

if (ws_uri_prefix !== 'ws://') {
return false
}

ws_uri = ws_uri.substr(5);
slash_idx = ws_uri.indexOf('/');

if (slash_idx === -1) {
ws_uri_hostport = ws_uri;
} else {
ws_uri_hostport = ws_uri.substr(0,slash_idx);
ws_uri = ws_uri.substr(slash_idx);
query_idx = ws_uri.indexOf('?');

if (query_idx === -1) {
ws_uri_path = ws_uri.substr(1);
} else {
ws_uri_path = ws_uri.substr(1, query_idx-1);
ws_uri_query = ws_uri.substr(query_idx+1);
}
}

return {
host: ws_uri_hostport,
ws_path: ws_uri_path,
ws_query: ws_uri_query
};
}


// If data is already set (default values) then directly go.
if (sip_uri && sip_password && ws_uri)
Expand Down

0 comments on commit ea0b054

Please sign in to comment.