()
| 11 | } |
| 12 | |
| 13 | _connect() { |
| 14 | clearTimeout(this._reconnectTimer); |
| 15 | if (this._isConnected() || this._isConnecting()) return; |
| 16 | const ws = new WebSocket(this._endpoint()); |
| 17 | ws.binaryType = 'arraybuffer'; |
| 18 | ws.onopen = e => console.log('WS: server connected'); |
| 19 | ws.onmessage = e => this._onMessage(e.data); |
| 20 | ws.onclose = e => this._onDisconnect(); |
| 21 | ws.onerror = e => console.error(e); |
| 22 | this._socket = ws; |
| 23 | } |
| 24 | |
| 25 | _onMessage(msg) { |
| 26 | msg = JSON.parse(msg); |
no test coverage detected