Documentation
¶
Index ¶
- Constants
- type Device
- type Handler
- type Server
- func (s *Server) AddDevice(device *Device)
- func (s *Server) GetDevice(deviceID string) (*Device, bool)
- func (s *Server) HandleWebSocket(w http.ResponseWriter, r *http.Request)
- func (s *Server) ListDevices() []string
- func (s *Server) RemoveDevice(deviceID string)
- func (s *Server) Start(addr string) error
- func (s *Server) StartTLS(addr string, certFile string, keyFile string) error
- type Session
Constants ¶
const (
// MaxDevices is the maximum number of devices that can be connected simultaneously.
MaxDevices = 10000
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Device ¶
type Device struct {
ID string
Name string
Conn *jsonrpc2.Conn
Sessions map[string]*Session
ConnectedAt time.Time
// contains filtered or unexported fields
}
Device represents a device connected to the server.
func (*Device) AddSession ¶
AddSession adds a session to the device.
func (*Device) GetSession ¶
GetSession returns a session by ID.
func (*Device) RemoveSession ¶
RemoveSession removes a session from the device.
func (*Device) SessionCount ¶
SessionCount returns the number of active sessions.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler implements jsonrpc2.Handler to process device messages.
func NewHandler ¶
NewHandler creates a new handler for a device.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server manages connected devices.
func NewWithSecurityKey ¶
NewWithSecurityKey creates a new server instance with authentication.
func (*Server) AddDevice ¶
AddDevice adds a device to the server with LRU eviction if limit is reached.
func (*Server) HandleWebSocket ¶
func (s *Server) HandleWebSocket(w http.ResponseWriter, r *http.Request)
HandleWebSocket processes WebSocket connections.
func (*Server) ListDevices ¶
ListDevices returns the list of connected device IDs.
func (*Server) RemoveDevice ¶
RemoveDevice removes a device from the server.