You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

strophe.logger.js 689B

1234567891011121314151617181920
  1. /* global Strophe */
  2. module.exports = function () {
  3. Strophe.addConnectionPlugin('logger', {
  4. // logs raw stanzas and makes them available for download as JSON
  5. connection: null,
  6. log: [],
  7. init: function (conn) {
  8. this.connection = conn;
  9. this.connection.rawInput = this.log_incoming.bind(this);
  10. this.connection.rawOutput = this.log_outgoing.bind(this);
  11. },
  12. log_incoming: function (stanza) {
  13. this.log.push([new Date().getTime(), 'incoming', stanza]);
  14. },
  15. log_outgoing: function (stanza) {
  16. this.log.push([new Date().getTime(), 'outgoing', stanza]);
  17. }
  18. });
  19. };