summaryrefslogtreecommitdiffstats
path: root/webapp/actions/websocket_actions.jsx
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2016-11-10 09:22:06 -0500
committerHarrison Healey <harrisonmhealey@gmail.com>2016-11-10 09:22:06 -0500
commit8c76560b4849f8d1fdc3c3f1c2f1877459a30fca (patch)
treed373ee86ac86f6613f24f2c82ca09aa6144f5c33 /webapp/actions/websocket_actions.jsx
parent39675afab4ba6e22b834aa6ff8d7dab2a35c5a8d (diff)
downloadchat-8c76560b4849f8d1fdc3c3f1c2f1877459a30fca.tar.gz
chat-8c76560b4849f8d1fdc3c3f1c2f1877459a30fca.tar.bz2
chat-8c76560b4849f8d1fdc3c3f1c2f1877459a30fca.zip
Fix websocket on old versions of IE11 (#4501)
Diffstat (limited to 'webapp/actions/websocket_actions.jsx')
-rw-r--r--webapp/actions/websocket_actions.jsx49
1 files changed, 26 insertions, 23 deletions
diff --git a/webapp/actions/websocket_actions.jsx b/webapp/actions/websocket_actions.jsx
index 431922b0d..36c6cbdc9 100644
--- a/webapp/actions/websocket_actions.jsx
+++ b/webapp/actions/websocket_actions.jsx
@@ -30,34 +30,37 @@ import {browserHistory} from 'react-router/es6';
const MAX_WEBSOCKET_FAILS = 7;
export function initialize() {
- if (window.WebSocket) {
- let connUrl = Utils.getSiteURL();
+ if (!window.WebSocket) {
+ console.log('Browser does not support websocket'); //eslint-disable-line no-console
+ return;
+ }
- // replace the protocol with a websocket one
- if (connUrl.startsWith('https:')) {
- connUrl = connUrl.replace(/^https:/, 'wss:');
- } else {
- connUrl = connUrl.replace(/^http:/, 'ws:');
- }
+ let connUrl = Utils.getSiteURL();
- // append a port number if one isn't already specified
- if (!(/:\d+$/).test(connUrl)) {
- if (connUrl.startsWith('wss:')) {
- connUrl += ':' + global.window.mm_config.WebsocketSecurePort;
- } else {
- connUrl += ':' + global.window.mm_config.WebsocketPort;
- }
+ // replace the protocol with a websocket one
+ if (connUrl.startsWith('https:')) {
+ connUrl = connUrl.replace(/^https:/, 'wss:');
+ } else {
+ connUrl = connUrl.replace(/^http:/, 'ws:');
+ }
+
+ // append a port number if one isn't already specified
+ if (!(/:\d+$/).test(connUrl)) {
+ if (connUrl.startsWith('wss:')) {
+ connUrl += ':' + global.window.mm_config.WebsocketSecurePort;
+ } else {
+ connUrl += ':' + global.window.mm_config.WebsocketPort;
}
+ }
- // append the websocket api path
- connUrl += Client.getUsersRoute() + '/websocket';
+ // append the websocket api path
+ connUrl += Client.getUsersRoute() + '/websocket';
- WebSocketClient.setEventCallback(handleEvent);
- WebSocketClient.setFirstConnectCallback(handleFirstConnect);
- WebSocketClient.setReconnectCallback(handleReconnect);
- WebSocketClient.setCloseCallback(handleClose);
- WebSocketClient.initialize(connUrl);
- }
+ WebSocketClient.setEventCallback(handleEvent);
+ WebSocketClient.setFirstConnectCallback(handleFirstConnect);
+ WebSocketClient.setReconnectCallback(handleReconnect);
+ WebSocketClient.setCloseCallback(handleClose);
+ WebSocketClient.initialize(connUrl);
}
export function close() {