Changeset 0.33.0 (#207)
Co-authored-by: Jeffrey Smith <jasafpro@gmail.com> Co-committed-by: Jeffrey Smith <jasafpro@gmail.com>
This commit is contained in:
@@ -10,6 +10,8 @@ import (
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/gorilla/websocket"
|
||||
|
||||
"chat-switchboard/metrics"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -121,6 +123,7 @@ func (h *Hub) HandleWebSocket(c *gin.Context) {
|
||||
h.mu.Unlock()
|
||||
|
||||
log.Printf("[ws] connected: %s (user=%s, total=%d)", connID, userID, h.ConnCount())
|
||||
metrics.WebSocketConnections.Inc()
|
||||
|
||||
// Subscribe this connection to bus events destined for clients
|
||||
conn.subscribeToBus()
|
||||
@@ -214,6 +217,7 @@ func (h *Hub) removeConn(conn *Conn) {
|
||||
}
|
||||
|
||||
log.Printf("[ws] disconnected: %s (total=%d)", conn.id, h.ConnCount())
|
||||
metrics.WebSocketConnections.Dec()
|
||||
|
||||
// Publish presence offline (only if no other conns for this user)
|
||||
if len(h.ConnsByUser(conn.userID)) == 0 {
|
||||
|
||||
Reference in New Issue
Block a user