feat: add Close() method to app, context aware channels

This commit is contained in:
2025-07-31 14:54:40 -05:00
parent a25c550648
commit e608843b09
4 changed files with 89 additions and 11 deletions

View File

@@ -44,6 +44,15 @@ func ListenWebsocket(conn *websocket.Conn, c chan ChanMsg) {
Raw: bytes,
}
c <- chanMsg
// Use non-blocking send to avoid hanging on closed channel
select {
case c <- chanMsg:
// Message sent successfully
default:
// Channel is full or closed, break out of loop
slog.Warn("Websocket message channel is full or closed, stopping listener")
close(c)
return
}
}
}