document path-to-room

This commit is contained in:
Philipp Hancke 2013-12-30 09:23:23 +01:00 committed by Yana Stamcheva
parent 905d54bee4
commit 8f46d961ef
1 changed files with 20 additions and 11 deletions

31
app.js
View File

@ -13,19 +13,18 @@ window.onbeforeunload = closePageWarning;
function init() { function init() {
RTC = setupRTC(); RTC = setupRTC();
if (RTC === null) { if (RTC === null) {
window.location.href = '/webrtcrequired.html'; window.location.href = 'webrtcrequired.html';
return; return;
} else if (RTC.browser != 'chrome') { } else if (RTC.browser != 'chrome') {
window.location.href = '/chromeonly.html'; window.location.href = 'chromeonly.html';
return; return;
} }
RTCPeerconnection = RTC.peerconnection; RTCPeerconnection = RTC.peerconnection;
connection = new Strophe.Connection(document.getElementById('boshURL').value || config.bosh || '/http-bind'); connection = new Strophe.Connection(document.getElementById('boshURL').value || config.bosh || '/http-bind');
/* if (connection.disco) {
connection.rawInput = function (data) { console.log('RECV: ' + data); }; // for chrome, add multistream cap
connection.rawOutput = function (data) { console.log('SEND: ' + data); }; }
*/
connection.jingle.pc_constraints = RTC.pc_constraints; connection.jingle.pc_constraints = RTC.pc_constraints;
var jid = document.getElementById('jid').value || config.hosts.domain || window.location.hostname; var jid = document.getElementById('jid').value || config.hosts.domain || window.location.hostname;
@ -49,6 +48,14 @@ function doJoin() {
var roomnode = null; var roomnode = null;
var path = window.location.pathname; var path = window.location.pathname;
var roomjid; var roomjid;
/*
* this is making assumptions about how the URL->room mapping happens.
* It currently assumes deployment at root, with a rewrite like the
* following one (for nginx):
location ~ ^/([a-zA-Z0-9]+)$ {
rewrite ^/(.*)$ / break;
}
*/
if (path.length > 1) { if (path.length > 1) {
roomnode = path.substr(1).toLowerCase(); roomnode = path.substr(1).toLowerCase();
} else { } else {
@ -100,11 +107,12 @@ $(document).bind('remotestreamadded.jingle', function (event, data, sid) {
} }
var sess = connection.jingle.sessions[sid]; var sess = connection.jingle.sessions[sid];
var vid = document.createElement('video'); var vid = document.createElement('video');
console.log(sess); // FIXME: the span should not be created here but on muc join
var span = document.createElement('span'); var span = document.createElement('span');
// FIXME: how to name this span? sess.peerjid is not right for jingle clients if (data.peerjid) {
//console.log('peer: ', Strophe.getResourceFromJid(sess.peerjid)); // FIXME: how to name this span? data.peerjid is not set for jingle clients
//span.id = 'remoteVideocontainer_' + Strophe.getResourceFromJid(sess.peerjid); span.id = 'participant_' + Strophe.getResourceFromJid(data.peerjid);
}
span.className = 'videocontainer'; span.className = 'videocontainer';
var id = 'remoteVideo_' + sid + '_' + data.stream.id; var id = 'remoteVideo_' + sid + '_' + data.stream.id;
vid.id = id; vid.id = id;
@ -123,6 +131,8 @@ $(document).bind('remotestreamadded.jingle', function (event, data, sid) {
data.stream.onended = function () { data.stream.onended = function () {
console.log('stream ended', this.id); console.log('stream ended', this.id);
var src = $('#' + id).attr('src'); var src = $('#' + id).attr('src');
// FIXME: likewise, the parent should not be removed here
// but on MUC part
$('#' + id).parent().remove(); $('#' + id).parent().remove();
if (src === $('#largeVideo').attr('src')) { if (src === $('#largeVideo').attr('src')) {
// this is currently displayed as large // this is currently displayed as large
@ -159,7 +169,6 @@ $(document).bind('callincoming.jingle', function (event, sid) {
}); });
$(document).bind('callactive.jingle', function (event, videoelem, sid) { $(document).bind('callactive.jingle', function (event, videoelem, sid) {
console.log('call active');
if (videoelem.attr('id').indexOf('mixedmslabel') == -1) { if (videoelem.attr('id').indexOf('mixedmslabel') == -1) {
// ignore mixedmslabela0 and v0 // ignore mixedmslabela0 and v0
videoelem.show(); videoelem.show();