Documentation
¶
Overview ¶
Package server maneja las conexiones WebSocket y el encolamiento de trabajos.
Package server maneja las conexiones WebSocket y el encolamiento de trabajos.
Index ¶
- type ClientRegistry
- func (r *ClientRegistry) Add(conn *websocket.Conn)
- func (r *ClientRegistry) Broadcast(fn func(*websocket.Conn) error)
- func (r *ClientRegistry) Contains(conn *websocket.Conn) bool
- func (r *ClientRegistry) Count() int
- func (r *ClientRegistry) ForEach(fn func(*websocket.Conn))
- func (r *ClientRegistry) Remove(conn *websocket.Conn)
- type Config
- type Message
- type PrintJob
- type PrinterLister
- type Response
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClientRegistry ¶
type ClientRegistry struct {
// contains filtered or unexported fields
}
ClientRegistry manages connected WebSocket clients thread-safely
func NewClientRegistry ¶
func NewClientRegistry() *ClientRegistry
NewClientRegistry creates a new client registry
func (*ClientRegistry) Add ¶
func (r *ClientRegistry) Add(conn *websocket.Conn)
Add registers a new client connection
func (*ClientRegistry) Broadcast ¶
func (r *ClientRegistry) Broadcast(fn func(*websocket.Conn) error)
Broadcast sends a message to all connected clients
func (*ClientRegistry) Contains ¶
func (r *ClientRegistry) Contains(conn *websocket.Conn) bool
Contains checks if a client is registered
func (*ClientRegistry) Count ¶
func (r *ClientRegistry) Count() int
Count returns the number of connected clients
func (*ClientRegistry) ForEach ¶
func (r *ClientRegistry) ForEach(fn func(*websocket.Conn))
ForEach executes a function for each connected client
func (*ClientRegistry) Remove ¶
func (r *ClientRegistry) Remove(conn *websocket.Conn)
Remove unregisters a client connection
type Message ¶
type Message struct {
Tipo string `json:"tipo"`
ID string `json:"id,omitempty"`
Datos json.RawMessage `json:"datos,omitempty"`
}
Message represents incoming WebSocket message
type PrintJob ¶
type PrintJob struct {
ID string `json:"id"`
ClientConn *websocket.Conn `json:"-"`
Document json.RawMessage `json:"datos"`
ReceivedAt time.Time `json:"received_at"`
}
PrintJob represents a queued print request
type PrinterLister ¶
type PrinterLister interface {
GetPrinters(forceRefresh bool) ([]connection.PrinterDetail, error)
GetSummary() printer.Summary
}
type Response ¶
type Response struct {
Tipo string `json:"tipo"`
ID string `json:"id,omitempty"`
Status string `json:"status,omitempty"`
Mensaje string `json:"mensaje,omitempty"`
Current int `json:"current,omitempty"`
Capacity int `json:"capacity,omitempty"`
}
Response represents outgoing WebSocket message
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server manages WebSocket connections and job queue
func NewServer ¶
func NewServer(cfg Config, discovery PrinterLister) *Server
NewServer creates a new WebSocket server
func (*Server) HandleWebSocket ¶
func (s *Server) HandleWebSocket(w http.ResponseWriter, r *http.Request)
HandleWebSocket handles WebSocket connections
func (*Server) NotifyClient ¶
NotifyClient sends a result back to a specific client
func (*Server) QueueStatus ¶
QueueStatus returns current and max queue size