mirror of
https://github.com/RobinLinus/snapdrop.git
synced 2025-05-16 07:30:12 -07:00
Don’t reconnect if already connecting
This commit is contained in:
parent
9c9ca70d05
commit
3ac40fb3d7
@ -9,7 +9,7 @@ class ServerConnection {
|
||||
}
|
||||
|
||||
_connect() {
|
||||
if (this._isConnected()) return;
|
||||
if (this._isConnected() || this._isConnecting()) return;
|
||||
const ws = new WebSocket(this._endpoint());
|
||||
ws.binaryType = 'arraybuffer';
|
||||
ws.onopen = e => console.log('WS: server connected');
|
||||
@ -24,6 +24,10 @@ class ServerConnection {
|
||||
return this._socket && this._socket.readyState === this._socket.OPEN;
|
||||
}
|
||||
|
||||
_isConnecting() {
|
||||
return this._socket && this._socket.readyState === this._socket.CONNECTING;
|
||||
}
|
||||
|
||||
_onMessage(msg) {
|
||||
msg = JSON.parse(msg);
|
||||
console.log('WS:', msg);
|
||||
|
Loading…
x
Reference in New Issue
Block a user