websocket

package
v1.0.0-rc.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 3, 2026 License: EPL-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
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

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 GetManager

func GetManager() *Manager

GetManager returns the singleton WebSocket manager

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

func (m *Manager) GetControlConnectionsCount() int

GetControlConnectionsCount returns the number of control connections

func (*Manager) GetMessageConnectionsCount

func (m *Manager) GetMessageConnectionsCount() int

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'
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL