-
-
Save domadev812/a087bb68757b1fa614a4f16663960d3e to your computer and use it in GitHub Desktop.
SimpleRTC Demo Code
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
<div id="vid-box"></div> | |
<form name="loginForm" id="login" action="#" onsubmit="return login(this);"> | |
<input type="text" name="username" id="username" placeholder="Pick a username!" /> | |
<input type="submit" name="login_submit" value="Log In"> | |
</form> | |
<form name="callForm" id="call" action="#" onsubmit="return makeCall(this);"> | |
<input type="text" name="number" placeholder="Enter user to dial!" /> | |
<input type="submit" value="Call"/> | |
</form> |
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
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> | |
<script src="https://cdn.pubnub.com/sdk/javascript/pubnub.4.17.0.js"></script> | |
<script src="https://cdn.pubnub.com/webrtc/webrtc.js"></script> |
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
var video_out = document.getElementById("vid-box"); |
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
function login(form) { | |
var phone = window.phone = PHONE({ | |
number : form.username.value || "Anonymous", // listen on username line else Anonymous | |
publish_key : 'your_pub_key', | |
subscribe_key : 'your_sub_key', | |
}); | |
phone.ready(function(){ form.username.style.background="#55ff5b"; }); | |
phone.receive(function(session){ | |
session.connected(function(session) { video_out.appendChild(session.video); }); | |
session.ended(function(session) { video_out.innerHTML=''; }); | |
}); | |
return false; // So the form does not submit. | |
} |
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
function makeCall(form){ | |
if (!window.phone) alert("Login First!"); | |
else phone.dial(form.number.value); | |
return false; | |
} |
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
cd <project-dir> | |
# Python 2 | |
python -m SimpleHTTPServer <portNo> | |
# Python 3 | |
python -m http.server <portNo> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment