2014-04-13 12:30:47 +00:00
|
|
|
/* global Strophe */
|
2013-12-19 09:39:32 +00:00
|
|
|
Strophe.addConnectionPlugin('logger', {
|
|
|
|
// logs raw stanzas and makes them available for download as JSON
|
|
|
|
connection: null,
|
|
|
|
log: [],
|
|
|
|
init: function (conn) {
|
|
|
|
this.connection = conn;
|
2014-03-01 07:39:39 +00:00
|
|
|
this.connection.rawInput = this.log_incoming.bind(this);
|
|
|
|
this.connection.rawOutput = this.log_outgoing.bind(this);
|
2013-12-19 09:39:32 +00:00
|
|
|
},
|
|
|
|
log_incoming: function (stanza) {
|
|
|
|
this.log.push([new Date().getTime(), 'incoming', stanza]);
|
|
|
|
},
|
|
|
|
log_outgoing: function (stanza) {
|
|
|
|
this.log.push([new Date().getTime(), 'outgoing', stanza]);
|
|
|
|
},
|
|
|
|
});
|