Created
May 6, 2014 13:01
-
-
Save bendecoste/66a4d1ce1848519978c3 to your computer and use it in GitHub Desktop.
goinstant webRTC example
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
x.html | |
<html><head> | |
<script src="https://cdn.goinstant.net/v1/platform.min.js"></script><style type="text/css"></style> | |
<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="script.js"></script> | |
</head> | |
<body onload="onLoad();"> | |
<p>Testing basic widget loading</p> | |
<div class="gi-webrtc"> | |
<div class="gi-webrtc-centered"> | |
<div class="gi-collapse-wrapper"> | |
<div class="gi-collapse"> | |
<span class="gi-icon"></span> | |
</div> | |
</div> | |
<div class="gi-list-wrapper"> | |
<ul class="gi-list"></ul> | |
</div> | |
</div> | |
</div> | |
</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/YOURACCOUNT/YOURAPP"; | |
goinstant.connect(url, function(err, conn, roomObj) { | |
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: 'gitest@5movez.com', | |
credential: 'gitesttest^' | |
}; | |
// Create a new instance of the WebRTC widget | |
var webrtc = new goinstant.widgets.WebRTC({ | |
room: roomObj, | |
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