Created
May 6, 2014 22:22
-
-
Save colinmacdonald/d7b9e8008a2ac66a8429 to your computer and use it in GitHub Desktop.
conftest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<script src="https://cdn.goinstant.net/v1/platform.min.js"></script> | |
<script type="text/javascript" src="https://cdn.goinstant.net/widgets/webrtc/latest/webrtc.min.js"></script> | |
<!-- CSS is optional --> | |
<link rel="stylesheet" href="https://cdn.goinstant.net/widgets/webrtc/latest/webrtc.css" /> | |
<script src="conftest1.js"></script> | |
</head> | |
<body onload="onLoad();"> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* jshint browser: true */ | |
/* global goinstant */ | |
window.onLoad = function() { | |
var url = "https://goinstant.net/ACCOUNT/APP"; | |
goinstant.connect(url, function(err, conn, room) { | |
if (err) throw err; | |
window.room = room; | |
if (!goinstant.widgets.WebRTC.supported) { | |
window.alert('Your browser does not support webrtc'); | |
return; | |
} | |
// Google's public STUN server | |
var stun = { | |
url: 'stun:stun.l.google.com:19302' | |
}; | |
// A free TURN server from http://numb.viagenie.ca | |
// Be careful with this kind of auth on the client as the username and password is exposed to EVERYONE! | |
// I set up this turn server just using a bogus email and password as you can see below | |
var turn = { | |
url: 'turn:numb.viagenie.ca', | |
username: 'USER', | |
credential: 'CRED' | |
}; | |
// Create a new instance of the WebRTC widget | |
var webrtc = new goinstant.widgets.WebRTC({ | |
room: room, | |
autoStart: true, | |
peerConnectionConfig: { | |
iceServers: [stun, turn] | |
} | |
}); | |
// Initialize the WebRTC widget | |
webrtc.initialize(function(err) { | |
if (err) { | |
throw err; | |
} | |
}); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment