123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- /* global Strophe */
- import ConnectionPlugin from './ConnectionPlugin';
-
- /**
- * Logs raw stanzas and makes them available for download as JSON
- */
- class StropheLogger extends ConnectionPlugin {
- /**
- *
- */
- constructor() {
- super();
- this.log = [];
- }
-
- /**
- *
- * @param connection
- */
- init(connection) {
- super.init(connection);
- this.connection.rawInput = this.logIncoming.bind(this);
- this.connection.rawOutput = this.logOutgoing.bind(this);
- }
-
- /**
- *
- * @param stanza
- */
- logIncoming(stanza) {
- this.log.push([ new Date().getTime(), 'incoming', stanza ]);
- }
-
- /**
- *
- * @param stanza
- */
- logOutgoing(stanza) {
- this.log.push([ new Date().getTime(), 'outgoing', stanza ]);
- }
- }
-
- /**
- *
- */
- export default function() {
- Strophe.addConnectionPlugin('logger', new StropheLogger());
- }
|