Skip to content

Commit

Permalink
update sample to work without a lib
Browse files Browse the repository at this point in the history
  • Loading branch information
samccone committed Apr 13, 2013
1 parent d2437a2 commit e1ea188
Showing 1 changed file with 18 additions and 23 deletions.
41 changes: 18 additions & 23 deletions public/js/sample.js
@@ -1,31 +1,26 @@
var ctx = new webkitAudioContext()
, src

console.log = function(message) {
document.getElementById('console').innerHTML += message + "\n";
}

rtc.on('add remote stream', function(stream, socketId) {
console.log("ADDING REMOTE STREAM...");
connect(stream);
});

rtc.on('connect', function() {
console.log("** RTC connected");
});
var ws = new WebSocket("ws:"+window.location.href.split(":")[1]+":8000");

rtc.createStream({audio: true}, function(){}, streamErr);

function connect( stream ){
var audio = new Audio();
audio.src = webkitURL.createObjectURL(stream);
audio.play();
}
ws.onmessage = function(d) {
d = JSON.parse(d.data);
if (d.type === "assigned_id") {
this._id = d.id;
console.log("id received");
} else {
console.log(d);
}
};

function streamErr(){
alert('O noes! couldn\'t get ur inputz');
function closeSocket() {
ws.send(JSON.stringify({
type: "close",
data: {
id: ws._id
}
}));
}

window.onload = function() {
rtc.connect('ws://24.­250.­22.­134:­80001', '');
}
window.onbeforeunload = closeSocket;

0 comments on commit e1ea188

Please sign in to comment.