()
| 1288 | |
| 1289 | // Wait for connection and send |
| 1290 | const waitForConnection = () => { |
| 1291 | if (socket?.readyState === WebSocket.OPEN) { |
| 1292 | socket.send(JSON.stringify(messageData)); |
| 1293 | if (isFirstMessage) isFirstMessage = false; |
| 1294 | } else { |
| 1295 | setTimeout(waitForConnection, 5); |
| 1296 | } |
| 1297 | }; |
| 1298 | waitForConnection(); |
| 1299 | } |
| 1300 |