Avoid dispatching unneeded socket actions
This commit is contained in:
parent
7fb0cd3e6a
commit
7658e3bde7
File diff suppressed because one or more lines are too long
@ -152,6 +152,10 @@ export default function handleSocket({
|
||||
handlers[type](data);
|
||||
}
|
||||
|
||||
if (type.charAt(0) === '_') {
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch(action);
|
||||
});
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ export default class Socket {
|
||||
jitter: 0.25
|
||||
});
|
||||
this.handlers = [];
|
||||
this.connected = false;
|
||||
|
||||
this.connect();
|
||||
}
|
||||
@ -26,6 +27,7 @@ export default class Socket {
|
||||
}, this.connectTimeout);
|
||||
|
||||
this.ws.onopen = () => {
|
||||
this.connected = true;
|
||||
this.emit('_connected', true);
|
||||
clearTimeout(this.timeoutConnect);
|
||||
this.backoff.reset();
|
||||
@ -33,7 +35,10 @@ export default class Socket {
|
||||
};
|
||||
|
||||
this.ws.onclose = () => {
|
||||
if (this.connected) {
|
||||
this.connected = false;
|
||||
this.emit('_connected', false);
|
||||
}
|
||||
clearTimeout(this.timeoutConnect);
|
||||
clearTimeout(this.timeoutPing);
|
||||
if (!this.closing) {
|
||||
@ -57,6 +62,7 @@ export default class Socket {
|
||||
|
||||
if (msg.type === 'ping') {
|
||||
this.send('pong');
|
||||
return;
|
||||
}
|
||||
|
||||
this.emit(msg.type, msg.data);
|
||||
|
Loading…
Reference in New Issue
Block a user