streaming: socket.addEventListener('open', ...) --> socket.onopen, etc

This commit is contained in:
Alex Gleason 2023-08-25 17:17:26 -05:00
parent a93d77c851
commit 9da03aa053
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
1 changed files with 4 additions and 8 deletions

View File

@ -42,8 +42,7 @@ const streamingController: AppController = (c) => {
} }
} }
socket.addEventListener('open', async () => { socket.onopen = async () => {
console.log('websocket: connection opened');
if (!stream) return; if (!stream) return;
ws.subscribe(conn, { stream }); ws.subscribe(conn, { stream });
@ -58,14 +57,11 @@ const streamingController: AppController = (c) => {
} }
} }
} }
}); };
socket.addEventListener('message', (e) => console.log('websocket message: ', e.data)); socket.onclose = () => {
socket.addEventListener('close', () => {
console.log('websocket: connection closed');
ws.unsubscribeAll(socket); ws.unsubscribeAll(socket);
}); };
return response; return response;
}; };