Skip to content

Commit 53f77d6

Browse files
committed
Merge pull request pubnub#1 from GleasonK/gh-pages
Added Error Catching
2 parents 6e7adac + f1ed940 commit 53f77d6

File tree

4 files changed

+42
-12
lines changed

4 files changed

+42
-12
lines changed

js/rtc-controller.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ var CONTROLLER = window.CONTROLLER = function(phone){
130130
broadcast(streamHolder);
131131
};
132132

133-
CONTROLLER.dial = function(number){ // Authenticate here??
134-
var session = phone.dial(number, get_xirsys_servers()); // Dial Number
133+
CONTROLLER.dial = function(number, servers){ // Authenticate here??
134+
var session = phone.dial(number, servers); // Dial Number
135135
if (!session) return; // No Duplicate Dialing Allowed
136136
};
137137

@@ -281,20 +281,23 @@ var CONTROLLER = window.CONTROLLER = function(phone){
281281

282282
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
283283
// Request fresh TURN servers from XirSys - Need to explain.
284+
// room=default&application=default&domain=kevingleason.me&ident=gleasonk&secret=b9066b5e-1f75-11e5-866a-c400956a1e19
284285
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
285286
function get_xirsys_servers() {
286287
var servers;
287288
$.ajax({
288289
type: 'POST',
289-
url: 'https://api.xirsys.com/getIceServers',
290+
url: 'https://service.xirsys.com/ice',
290291
data: {
291292
room: 'default',
292293
application: 'default',
293-
domain: 'www.pubnub-example.com',
294-
ident: 'pubnub',
295-
secret: 'dec77661-9b0e-4b19-90d7-3bc3877e64ce',
294+
domain: 'kevingleason.me',
295+
ident: 'gleasonk',
296+
secret: 'b9066b5e-1f75-11e5-866a-c400956a1e19',
297+
secure: 1,
296298
},
297299
success: function(res) {
300+
console.log(res);
298301
res = JSON.parse(res);
299302
if (!res.e) servers = res.d.iceServers;
300303
},

minivid.html

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
</div>
3131

3232

33-
<form name="loginForm" id="login" action="#" onsubmit="return login(this);">
33+
<form name="loginForm" id="login" action="#" onsubmit="return errWrap(login,this);">
3434
<span class="input input--nao">
3535
<input class="input__field input__field--nao" type="text" name="username" id="username" placeholder="Enter A Username"/>
3636
<label class="input__label input__label--nao" for="username">
@@ -47,7 +47,7 @@
4747
</button>
4848
</form>
4949

50-
<form name="callForm" id="call" action="#" onsubmit="return makeCall(this);">
50+
<form name="callForm" id="call" action="#" onsubmit="return errWrap(makeCall,this);">
5151
<span class="input input--nao">
5252
<input class="input__field input__field--nao" type="text" name="number" id="call" placeholder="Enter User To Call!"/>
5353
<label class="input__label input__label--nao" for="number">
@@ -107,6 +107,15 @@
107107
$("#showModal").click();
108108
}
109109

110+
function errWrap(fxn, form){
111+
try {
112+
return fxn(form);
113+
} catch(err) {
114+
alert("WebRTC is currently only supported by Chrome, Opera, and Firefox");
115+
return false;
116+
}
117+
}
118+
110119
</script>
111120
<script src="js/modalEffects.js"></script>
112121
<script src="js/classie.js"></script>

minivid2.html

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
<input type="submit" name="login_submit" value="Log In">
3636
</form>
3737
-->
38-
<form name="loginForm" id="login" action="#" onsubmit="return login(this);">
38+
<form name="loginForm" id="login" action="#" onsubmit="return errWrap(login,this);">
3939
<span class="input input--nao">
4040
<input class="input__field input__field--nao" type="text" name="username" id="username" placeholder="Enter A Username"/>
4141
<label class="input__label input__label--nao" for="username">
@@ -60,7 +60,7 @@
6060
-->
6161

6262

63-
<form name="callForm" id="call" action="#" onsubmit="return makeCall(this);">
63+
<form name="callForm" id="call" action="#" onsubmit="return errWrap(makeCall,this);">
6464
<span class="input input--nao">
6565
<input class="input__field input__field--nao" type="text" name="number" id="call" placeholder="Enter User To Call!"/>
6666
<label class="input__label input__label--nao" for="number">
@@ -165,6 +165,15 @@
165165
$('#logs').append("<p>"+log+"</p>");
166166
}
167167

168+
function errWrap(fxn, form){
169+
try {
170+
return fxn(form);
171+
} catch(err) {
172+
alert("WebRTC is currently only supported by Chrome, Opera, and Firefox");
173+
return false;
174+
}
175+
}
176+
168177
</script>
169178

170179
<script>

stream.html

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
</div>
3030

3131

32-
<form name="streamForm" id="stream" action="#" onsubmit="return stream(this);">
32+
<form name="streamForm" id="stream" action="#" onsubmit="return errWrap(stream,this);">
3333
<span class="input input--nao">
3434
<input class="input__field input__field--nao" type="text" name="streamname" placeholder="Enter Stream Name" id="streamname"/>
3535
<label class="input__label input__label--nao" for="streamname">
@@ -47,7 +47,7 @@
4747
</form>
4848

4949

50-
<form name="watchForm" id="watch" action="#" onsubmit="return watch(this);">
50+
<form name="watchForm" id="watch" action="#" onsubmit="return errWrap(watch,this);">
5151
<span class="input input--nao">
5252
<input class="input__field input__field--nao" type="text" name="number" placeholder="Enter Stream To Watch!"/>
5353
<label class="input__label input__label--nao" for="number">
@@ -187,6 +187,15 @@
187187
embed_code.appendChild(document.createTextNode(embed.outerHTML));
188188
}
189189

190+
function errWrap(fxn, form){
191+
try {
192+
return fxn(form);
193+
} catch(err) {
194+
alert("WebRTC is currently only supported by Chrome, Opera, and Firefox");
195+
return false;
196+
}
197+
}
198+
190199
</script>
191200

192201
<script>

0 commit comments

Comments
 (0)