MCPcopy Create free account
hub / github.com/astercloud/aster / closeConnection

Method closeConnection

server/handlers/websocket.go:488–513  ·  view source on GitHub ↗

closeConnection closes a WebSocket connection

(wsConn *WebSocketConnection)

Source from the content-addressed store, hash-verified

486
487// closeConnection closes a WebSocket connection
488func (h *WebSocketHandler) closeConnection(wsConn *WebSocketConnection) {
489 h.mu.Lock()
490 delete(h.connections, wsConn.ID)
491 h.mu.Unlock()
492
493 // Cancel pending HITL requests for this connection
494 if h.hitlManager != nil {
495 h.hitlManager.CancelPendingRequests(wsConn.ID)
496 }
497
498 wsConn.cancel()
499 close(wsConn.Send)
500
501 if wsConn.Agent != nil {
502 h.registry.Unregister((*wsConn.Agent).ID())
503 if err := (*wsConn.Agent).Close(); err != nil {
504 logging.Error(wsConn.ctx, "failed to close agent", map[string]any{
505 "error": err.Error(),
506 })
507 }
508 }
509
510 logging.Info(wsConn.ctx, "websocket.disconnected", map[string]any{
511 "connection_id": wsConn.ID,
512 })
513}
514
515// GetStats returns WebSocket statistics
516func (h *WebSocketHandler) GetStats(c *gin.Context) {

Callers 1

readPumpMethod · 0.95

Calls 9

ErrorFunction · 0.92
InfoFunction · 0.92
deleteFunction · 0.85
CancelPendingRequestsMethod · 0.80
IDMethod · 0.65
CloseMethod · 0.65
ErrorMethod · 0.65
cancelMethod · 0.45
UnregisterMethod · 0.45

Tested by

no test coverage detected