summaryrefslogtreecommitdiffstats
path: root/webapp/client/websocket_client.jsx
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2016-11-14 07:09:41 -0500
committerChristopher Speller <crspeller@gmail.com>2016-11-14 07:09:41 -0500
commit323ce8b203c570ed6a1dd57b44d6637ad8207616 (patch)
treeefc3c61b905244bdb0e1ace0ce9f5ae4876644ad /webapp/client/websocket_client.jsx
parentd1207d34c1d99eba9ebf85c98d267ee7e955ea7d (diff)
parentb55ec6148caa93d54b660afe55408c643d217108 (diff)
downloadchat-323ce8b203c570ed6a1dd57b44d6637ad8207616.tar.gz
chat-323ce8b203c570ed6a1dd57b44d6637ad8207616.tar.bz2
chat-323ce8b203c570ed6a1dd57b44d6637ad8207616.zip
Merge branch 'release-3.5'
Diffstat (limited to 'webapp/client/websocket_client.jsx')
-rw-r--r--webapp/client/websocket_client.jsx11
1 files changed, 9 insertions, 2 deletions
diff --git a/webapp/client/websocket_client.jsx b/webapp/client/websocket_client.jsx
index 760c62b59..35be5c3df 100644
--- a/webapp/client/websocket_client.jsx
+++ b/webapp/client/websocket_client.jsx
@@ -8,6 +8,7 @@ const MAX_WEBSOCKET_RETRY_TIME = 300000; // 5 mins
export default class WebSocketClient {
constructor() {
this.conn = null;
+ this.connectionUrl = null;
this.sequence = 1;
this.connectFailCount = 0;
this.eventCallback = null;
@@ -18,16 +19,22 @@ export default class WebSocketClient {
this.closeCallback = null;
}
- initialize(connectionUrl, token) {
+ initialize(connectionUrl = this.connectionUrl, token) {
if (this.conn) {
return;
}
+ if (connectionUrl == null) {
+ console.log('websocket must have connection url'); //eslint-disable-line no-console
+ return;
+ }
+
if (this.connectFailCount === 0) {
console.log('websocket connecting to ' + connectionUrl); //eslint-disable-line no-console
}
this.conn = new WebSocket(connectionUrl);
+ this.connectionUrl = connectionUrl;
this.conn.onopen = () => {
if (token) {
@@ -150,7 +157,7 @@ export default class WebSocketClient {
if (this.conn && this.conn.readyState === WebSocket.OPEN) {
this.conn.send(JSON.stringify(msg));
- } else if (!this.conn || this.conn.readyState === WebSocket.Closed) {
+ } else if (!this.conn || this.conn.readyState === WebSocket.CLOSED) {
this.conn = null;
this.initialize();
}