()
| 52 | } |
| 53 | |
| 54 | connect() { |
| 55 | super.connect(); |
| 56 | |
| 57 | this.socket?.addEventListener('open', () => { |
| 58 | if (this._isFirstConnection) { |
| 59 | this._logger.info('First connection'); |
| 60 | this._isFirstConnection = false; |
| 61 | return; |
| 62 | } |
| 63 | |
| 64 | this._logger.info('Reconnecting'); |
| 65 | |
| 66 | for (const fullKey of Object.keys(this.subscriptions)) { |
| 67 | const [key, field] = splitStr(fullKey, '>', 2); |
| 68 | const [prefix, suffix] = splitStr(key, ':', 2); |
| 69 | |
| 70 | this.commandBuffer.push({ |
| 71 | type: RealtimeCommandType.SUBSCRIBE, |
| 72 | args: [prefix, suffix, field], |
| 73 | }); |
| 74 | } |
| 75 | |
| 76 | if (this.commandBuffer.length > 0) { |
| 77 | setTimeout(this.flushCommandBuffer); |
| 78 | } |
| 79 | }); |
| 80 | |
| 81 | this.socket?.addEventListener('message', (event) => { |
| 82 | this._handleMessage(new Uint8Array(event.data)); |
| 83 | }); |
| 84 | } |
| 85 | |
| 86 | // Get commands |
| 87 |
no test coverage detected