Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Commit

Permalink
Revert "MM-20664 Add client side ping pong (#6052)" (#6454)
Browse files Browse the repository at this point in the history
This reverts commit 58bb453.
  • Loading branch information
sudheerDev authored Sep 15, 2020
1 parent 451cb22 commit fd979e7
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 99 deletions.
29 changes: 0 additions & 29 deletions client/websocket_client.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
const MAX_WEBSOCKET_FAILS = 7;
const MIN_WEBSOCKET_RETRY_TIME = 3000; // 3 sec
const MAX_WEBSOCKET_RETRY_TIME = 300000; // 5 mins
const PING_TIME = 10000;
const PONG_WAIT_TIME = 2000;

export default class WebSocketClient {
constructor() {
Expand All @@ -21,7 +19,6 @@ export default class WebSocketClient {
this.missedEventCallback = null;
this.errorCallback = null;
this.closeCallback = null;
this.pingTimer = null;
}

initialize(connectionUrl = this.connectionUrl, token) {
Expand Down Expand Up @@ -57,8 +54,6 @@ export default class WebSocketClient {
this.firstConnectCallback();
}

this.clearPingPong();
this.createPingEvent();
this.connectFailCount = 0;
};

Expand All @@ -70,7 +65,6 @@ export default class WebSocketClient {
console.log('websocket closed'); //eslint-disable-line no-console
}

this.clearPingPong();
this.connectFailCount++;

if (this.closeCallback) {
Expand Down Expand Up @@ -104,7 +98,6 @@ export default class WebSocketClient {
if (this.errorCallback) {
this.errorCallback(evt);
}
this.clearPingPong();
};

this.conn.onmessage = (evt) => {
Expand All @@ -126,9 +119,6 @@ export default class WebSocketClient {
this.eventSequence = msg.seq + 1;
this.eventCallback(msg);
}

this.clearPingPong();
this.createPingEvent();
};
}

Expand Down Expand Up @@ -160,7 +150,6 @@ export default class WebSocketClient {
this.connectFailCount = 0;
this.sequence = 1;
if (this.conn && this.conn.readyState === WebSocket.OPEN) {
this.clearPingPong();
this.conn.onclose = () => {}; //eslint-disable-line no-empty-function
this.conn.close();
this.conn = null;
Expand Down Expand Up @@ -212,22 +201,4 @@ export default class WebSocketClient {
data.user_ids = userIds;
this.sendMessage('get_statuses_by_ids', data, callback);
}

createPingEvent() {
this.pingTimer = setInterval(() => {
this.sendMessage('ping');
this.waitForPong();
}, PING_TIME);
}

waitForPong() {
this.pongTimer = setTimeout(() => {
this.conn.onclose();
}, PONG_WAIT_TIME);
}

clearPingPong() {
clearInterval(this.pingTimer);
clearTimeout(this.pongTimer);
}
}
69 changes: 0 additions & 69 deletions client/websocket_client.test.jsx

This file was deleted.

2 changes: 1 addition & 1 deletion tests/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ beforeEach(() => {
afterEach(() => {
if (logs.length > 0 || warns.length > 0 || errors.length > 0) {
const message = 'Unexpected console logs' + logs + warns + errors;
if (message.includes('componentWillReceiveProps') || message.includes('websocket')) {
if (message.includes('componentWillReceiveProps')) {
return;
}
throw new Error(message);
Expand Down

0 comments on commit fd979e7

Please sign in to comment.