From 823f5709555a055b1fc73dc9e19cddbb0c23e54a Mon Sep 17 00:00:00 2001 From: lilia Date: Sun, 20 Sep 2015 00:30:21 -0700 Subject: [PATCH] Add more websocket debug logging // FREEBIE --- js/libtextsecure.js | 5 +++++ libtextsecure/message_receiver.js | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/js/libtextsecure.js b/js/libtextsecure.js index df936114a6..cbc64a015c 100644 --- a/js/libtextsecure.js +++ b/js/libtextsecure.js @@ -39400,6 +39400,7 @@ function generateKeys(count, progressCallback) { if (this.socket && this.socket.readyState !== WebSocket.CLOSED) { this.socket.close(); } + console.log('opening websocket'); this.socket = new WebSocket( this.url.replace('https://', 'wss://').replace('http://', 'ws://') + '/v1/websocket/?login=' + encodeURIComponent(this.username) @@ -39408,6 +39409,7 @@ function generateKeys(count, progressCallback) { this.socket.onclose = this.onclose.bind(this); this.socket.onerror = this.onerror.bind(this); + this.socket.onconnect = this.onconnect.bind(this); this.wsr = new WebSocketResource(this.socket, { handleRequest: this.handleRequest.bind(this), keepalive: { path: '/v1/keepalive', disconnect: true } @@ -39417,6 +39419,9 @@ function generateKeys(count, progressCallback) { this.socket.close(); delete this.listeners; }, + onconnect: function() { + console.log('websocket connected'); + }, onerror: function(error) { console.log('websocket error', error); this.socketError = error; diff --git a/libtextsecure/message_receiver.js b/libtextsecure/message_receiver.js index 7557c177c5..07a5cf00d4 100644 --- a/libtextsecure/message_receiver.js +++ b/libtextsecure/message_receiver.js @@ -25,6 +25,7 @@ if (this.socket && this.socket.readyState !== WebSocket.CLOSED) { this.socket.close(); } + console.log('opening websocket'); this.socket = new WebSocket( this.url.replace('https://', 'wss://').replace('http://', 'ws://') + '/v1/websocket/?login=' + encodeURIComponent(this.username) @@ -33,6 +34,7 @@ this.socket.onclose = this.onclose.bind(this); this.socket.onerror = this.onerror.bind(this); + this.socket.onconnect = this.onconnect.bind(this); this.wsr = new WebSocketResource(this.socket, { handleRequest: this.handleRequest.bind(this), keepalive: { path: '/v1/keepalive', disconnect: true } @@ -42,6 +44,9 @@ this.socket.close(); delete this.listeners; }, + onconnect: function() { + console.log('websocket connected'); + }, onerror: function(error) { console.log('websocket error', error); this.socketError = error;