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)
- 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
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
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 (*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)
RemoveConnection removes a WebSocket connection
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' )