add logging

This commit is contained in:
Philipp Hancke 2013-12-22 19:39:41 +01:00 committed by Yana Stamcheva
parent 486bc01976
commit 667551c7a0
5 changed files with 171 additions and 12 deletions

27
app.js
View File

@ -361,9 +361,30 @@ $(window).bind('unload', function () {
}
});
/*
* Appends the given message to the chat conversation.
*/
// <a onclick="dump(event.target);">my download button</a>
function dump(elem, filename){
elem.download = filename || 'xmpplog.json';
elem.href = 'data:application/json;charset=utf-8,\n';
var data = {};
data.time = new Date();
data.url = window.location.href;
data.ua = navigator.userAgent;
if (connection.logger) {
data.xmpp = connection.logger.log;
}
if (connection.jingle) {
Object.keys(connection.jingle.sessions).forEach(function (sid) {
var session = connection.jingle.sessions[sid];
if (session.peerconnection && session.peerconnection.updateLog) {
// FIXME: should probably be a .dump call
data["jingle_" + session.sid] = session.peerconnection.updateLog;
}
});
}
elem.href += encodeURIComponent(JSON.stringify(data, null, ' '));
return false;
}
function updateChatConversation(nick, message)
{
var divClassName = '';

View File

@ -13,11 +13,4 @@ Strophe.addConnectionPlugin('logger', {
log_outgoing: function (stanza) {
this.log.push([new Date().getTime(), 'outgoing', stanza]);
},
// <a onclick="connection.logger.dump(event.target);">my download button</a>
dump: function (what, filename){
what.download = filename || 'xmpplog.json';
what.href = 'data:application/json;charset=utf-8,\n';
what.href += encodeURIComponent(JSON.stringify(this.log, null, ' '));
return true;
}
});

View File

@ -29,7 +29,6 @@
<a class="button" onclick="openLinkDialog();"><i title="Invite others" class="fa fa-link fa-lg"></i></a>
<div class="header_button_separator"></div>
<a class="button" onclick='openChat();'><i id="chat" title="Open chat" class="fa fa-comments fa-lg"></i></a>
<!--i class='fa fa-external-link'>&nbsp;</i>Others can join you by just going to <span id='roomurl'></span-->
</div>
</div>
<div id="settings">

View File

@ -72,7 +72,7 @@ ColibriFocus.prototype.makeConference = function (peers) {
ob.channels.push([]);
});
this.peerconnection = new RTC.peerconnection(this.connection.jingle.ice_config, this.connection.jingle.pc_constraints);
this.peerconnection = new TraceablePeerConnection(this.connection.jingle.ice_config, this.connection.jingle.pc_constraints);
this.peerconnection.addStream(this.connection.jingle.localStream);
this.peerconnection.oniceconnectionstatechange = function (event) {
console.warn('ice connection state changed to', ob.peerconnection.iceConnectionState);

File diff suppressed because one or more lines are too long