Fix websocket on old versions of IE11 (#4501)
Этот коммит содержится в:
коммит произвёл
Harrison Healey
родитель
39675afab4
Коммит
8c76560b48
@@ -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();
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user