backend: better socket handling

This commit is contained in:
2025-02-15 02:19:14 -08:00
parent a3e0758205
commit b7ad824eb5
2 changed files with 13 additions and 8 deletions

View File

@@ -78,10 +78,11 @@ apiRouter.post("/volume", async (req, res) => {
});
apiRouter.ws("/events", (ws, req) => {
console.log(req.query);
console.log("Events client connected");
mediaPlayer.subscribe(ws);
ws.on("close", () => {
console.log("Events client disconnected");
mediaPlayer.unsubscribe(ws);
});
});