feat(chat): prevent ws not open errors

This commit is contained in:
ItzCrazyKns
2024-10-15 18:04:50 +05:30
parent 7532c436db
commit 3a01eebc04
6 changed files with 59 additions and 15 deletions

View File

@ -78,6 +78,18 @@ export const handleConnection = async (
ws.close();
}
const interval = setInterval(() => {
if (ws.readyState === ws.OPEN) {
ws.send(
JSON.stringify({
type: 'signal',
data: 'open',
}),
);
clearInterval(interval);
}
}, 5);
ws.on(
'message',
async (message) =>