Documentation
¶
Index ¶
- Constants
- type Connection
- type ControlHandler
- type Manager
- func (m *Manager) AddConnection(wsType WebSocketType, id string, conn *websocket.Conn) *Connection
- func (m *Manager) GetAllConnections(wsType WebSocketType) map[string]*Connection
- func (m *Manager) GetConnection(wsType WebSocketType, id string) (*Connection, bool)
- func (m *Manager) GetControlConnectionsCount() int
- func (m *Manager) GetMessageConnectionsCount() int
- func (m *Manager) RemoveConnection(wsType WebSocketType, id string, conn *Connection)
- type WebSocketType
Constants ¶
const ( OpcodePing byte = 0x9 OpcodePong byte = 0xA OpcodeACK byte = 0xB OpcodeControlSignal byte = 0xC OpcodeMSG byte = 0xD OpcodeReceipt byte = 0xE OpcodeResourceSignal byte = 0xF )
WebSocket opcodes
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection struct {
Conn *websocket.Conn
ID string
Type WebSocketType
// contains filtered or unexported fields
}
Connection represents a WebSocket connection with metadata
func (*Connection) IsClosed ¶
func (c *Connection) IsClosed() bool
IsClosed checks if a connection is closed
func (*Connection) WriteMessage ¶
func (c *Connection) WriteMessage(messageType int, data []byte) error
WriteMessage sends a WebSocket message when the connection is still open.
type ControlHandler ¶
type ControlHandler struct {
// contains filtered or unexported fields
}
ControlHandler handles control WebSocket connections
func NewControlHandler ¶
func NewControlHandler() *ControlHandler
NewControlHandler creates a new control WebSocket handler backed by the process singleton manager.
func NewControlHandlerWithManager ¶ added in v1.0.2
func NewControlHandlerWithManager(m *Manager) *ControlHandler
NewControlHandlerWithManager creates a control WebSocket handler with an explicit connection manager.
func (*ControlHandler) Handle ¶
func (h *ControlHandler) Handle(w http.ResponseWriter, r *http.Request)
Handle handles the WebSocket upgrade and connection
func (*ControlHandler) SendControlSignal ¶
func (h *ControlHandler) SendControlSignal(containerID string) error
SendControlSignal sends a control signal to a specific container
func (*ControlHandler) SendControlSignalToAll ¶
func (h *ControlHandler) SendControlSignalToAll(changedConfigIDs []string)
SendControlSignalToAll sends a control signal to all connected containers
func (*ControlHandler) SendResourceSignal ¶
func (h *ControlHandler) SendResourceSignal()
SendResourceSignal sends a resource signal to all connected containers
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages WebSocket connections
func NewManager ¶ added in v1.0.2
func NewManager() *Manager
NewManager creates an isolated WebSocket connection registry.
func (*Manager) AddConnection ¶
func (m *Manager) AddConnection(wsType WebSocketType, id string, conn *websocket.Conn) *Connection
AddConnection adds a WebSocket connection
func (*Manager) GetAllConnections ¶
func (m *Manager) GetAllConnections(wsType WebSocketType) map[string]*Connection
GetAllConnections returns all connections of a given type
func (*Manager) GetConnection ¶
func (m *Manager) GetConnection(wsType WebSocketType, id string) (*Connection, bool)
GetConnection gets a connection by type and ID
func (*Manager) GetControlConnectionsCount ¶
GetControlConnectionsCount returns the number of control connections
func (*Manager) GetMessageConnectionsCount ¶
GetMessageConnectionsCount returns the number of message connections
func (*Manager) RemoveConnection ¶
func (m *Manager) RemoveConnection(wsType WebSocketType, id string, conn *Connection)
RemoveConnection removes a WebSocket connection when conn still owns the map slot.
type WebSocketType ¶
type WebSocketType byte
WebSocketType represents the type of WebSocket connection
const ( // ControlWebSocket is for control signals ControlWebSocket WebSocketType = 'C' // MessageWebSocket is for real-time messages MessageWebSocket WebSocketType = 'M' )