Documentation
¶
Overview ¶
Package gateway provides the WebSocket control plane for omniagent.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AgentProcessor ¶
type AgentProcessor interface {
Process(ctx context.Context, sessionID, content string) (string, error)
}
AgentProcessor processes messages through an AI agent.
type AuthMessage ¶
type AuthMessage struct {
Token string `json:"token,omitempty"`
DeviceID string `json:"device_id,omitempty"`
}
AuthMessage represents an authentication message.
type ChatMessage ¶
type ChatMessage struct {
SessionID string `json:"session_id,omitempty"`
Content string `json:"content"`
Channel string `json:"channel,omitempty"`
ReplyTo string `json:"reply_to,omitempty"`
}
ChatMessage represents a chat message.
type Client ¶
type Client struct {
ID string
// contains filtered or unexported fields
}
Client represents a connected WebSocket client.
func (*Client) GetMetadata ¶
GetMetadata gets a metadata value.
func (*Client) SetMetadata ¶
SetMetadata sets a metadata value.
type Config ¶
type Config struct {
Address string
ReadTimeout time.Duration
WriteTimeout time.Duration
PingInterval time.Duration
Logger *slog.Logger
Agent AgentProcessor
}
Config configures the gateway server.
type DefaultMessageHandler ¶
type DefaultMessageHandler struct {
// contains filtered or unexported fields
}
DefaultMessageHandler provides a basic message handler implementation.
func NewDefaultMessageHandler ¶
func NewDefaultMessageHandler(gw *Gateway) *DefaultMessageHandler
NewDefaultMessageHandler creates a new default message handler.
type EventMessage ¶
type EventMessage struct {
Event string `json:"event"`
Channel string `json:"channel,omitempty"`
Data map[string]interface{} `json:"data,omitempty"`
}
EventMessage represents an event notification.
type Gateway ¶
type Gateway struct {
// contains filtered or unexported fields
}
Gateway is the WebSocket control plane server.
func (*Gateway) ClientCount ¶
ClientCount returns the number of connected clients.
func (*Gateway) OnMessage ¶
func (g *Gateway) OnMessage(handler MessageHandler)
OnMessage sets the message handler.
type Message ¶
type Message struct {
ID string `json:"id,omitempty"`
Type MessageType `json:"type"`
Channel string `json:"channel,omitempty"`
Content string `json:"content,omitempty"`
Data map[string]interface{} `json:"data,omitempty"`
Error string `json:"error,omitempty"`
Timestamp time.Time `json:"timestamp,omitempty"`
}
Message is the base message structure for gateway communication.
func NewChatResponse ¶
NewChatResponse creates a chat response message.
func NewErrorMessage ¶
NewErrorMessage creates an error message.
func NewEventMessage ¶
NewEventMessage creates an event message.
type MessageHandler ¶
MessageHandler handles incoming messages from clients.
type MessageType ¶
type MessageType string
MessageType represents the type of gateway message.
const ( // Client -> Gateway MessageTypeChat MessageType = "chat" MessageTypePing MessageType = "ping" MessageTypeAuth MessageType = "auth" MessageTypeSubscribe MessageType = "subscribe" // Gateway -> Client MessageTypeResponse MessageType = "response" MessageTypePong MessageType = "pong" MessageTypeError MessageType = "error" MessageTypeEvent MessageType = "event" )