summaryrefslogtreecommitdiffstats
path: root/webapp/client/websocket_client.jsx
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2016-07-27 09:54:43 -0400
committerChristopher Speller <crspeller@gmail.com>2016-07-27 09:54:42 -0400
commitfc7ae6ba65185719591d89a1be84fb3f9804943b (patch)
treed65c9338bca8502d884e982830747ad01cefb49c /webapp/client/websocket_client.jsx
parent199c55b5662789e27858a2da9461d4e2ea6026c5 (diff)
downloadchat-fc7ae6ba65185719591d89a1be84fb3f9804943b.tar.gz
chat-fc7ae6ba65185719591d89a1be84fb3f9804943b.tar.bz2
chat-fc7ae6ba65185719591d89a1be84fb3f9804943b.zip
Initialize and close WebSocket more accurately and consistently (#3683)
Diffstat (limited to 'webapp/client/websocket_client.jsx')
-rw-r--r--webapp/client/websocket_client.jsx11
1 files changed, 3 insertions, 8 deletions
diff --git a/webapp/client/websocket_client.jsx b/webapp/client/websocket_client.jsx
index 99d2311b7..aa78d8d98 100644
--- a/webapp/client/websocket_client.jsx
+++ b/webapp/client/websocket_client.jsx
@@ -10,7 +10,6 @@ export default class WebSocketClient {
this.conn = null;
this.sequence = 1;
this.connectFailCount = 0;
- this.manuallyClosed = false;
this.eventCallback = null;
this.responseCallbacks = {};
this.reconnectCallback = null;
@@ -27,8 +26,6 @@ export default class WebSocketClient {
console.log('websocket connecting to ' + connectionUrl); //eslint-disable-line no-console
}
- this.manuallyClosed = false;
-
this.conn = new WebSocket(connectionUrl);
this.conn.onopen = () => {
@@ -51,10 +48,6 @@ export default class WebSocketClient {
console.log('websocket closed'); //eslint-disable-line no-console
}
- if (this.manuallyClosed) {
- return;
- }
-
this.connectFailCount++;
if (this.closeCallback) {
@@ -124,11 +117,13 @@ export default class WebSocketClient {
}
close() {
- this.manuallyClosed = true;
this.connectFailCount = 0;
this.sequence = 1;
if (this.conn && this.conn.readyState === WebSocket.OPEN) {
+ this.conn.onclose = () => {}; //eslint-disable-line no-empty-function
this.conn.close();
+ this.conn = null;
+ console.log('websocket closed'); //eslint-disable-line no-console
}
}