feat(chat): prevent ws not open errors
This commit is contained in:
parent
7532c436db
commit
3a01eebc04
6 changed files with 59 additions and 15 deletions
|
|
@ -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) =>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue