Documentation
¶
Index ¶
- Constants
- type PicoChannel
- func (c *PicoChannel) EditMessage(ctx context.Context, chatID string, messageID string, content string) error
- func (c *PicoChannel) Send(ctx context.Context, msg bus.OutboundMessage) error
- func (c *PicoChannel) SendPlaceholder(ctx context.Context, chatID string) (string, error)
- func (c *PicoChannel) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (c *PicoChannel) Start(ctx context.Context) error
- func (c *PicoChannel) StartTyping(ctx context.Context, chatID string) (func(), error)
- func (c *PicoChannel) Stop(ctx context.Context) error
- func (c *PicoChannel) WebhookPath() string
- type PicoMessage
Constants ¶
const ( // TypeMessageSend is sent from client to server. TypeMessageSend = "message.send" TypeMediaSend = "media.send" TypePing = "ping" // TypeMessageCreate is sent from server to client. TypeMessageCreate = "message.create" TypeMessageUpdate = "message.update" TypeMediaCreate = "media.create" TypeTypingStart = "typing.start" TypeTypingStop = "typing.stop" TypeError = "error" TypePong = "pong" )
Protocol message types.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PicoChannel ¶
type PicoChannel struct {
*channels.BaseChannel
// contains filtered or unexported fields
}
PicoChannel implements the native Pico Protocol WebSocket channel. It serves as the reference implementation for all optional capability interfaces.
func NewPicoChannel ¶
func NewPicoChannel(cfg config.PicoConfig, messageBus *bus.MessageBus) (*PicoChannel, error)
NewPicoChannel creates a new Pico Protocol channel.
func (*PicoChannel) EditMessage ¶
func (c *PicoChannel) EditMessage(ctx context.Context, chatID string, messageID string, content string) error
EditMessage implements channels.MessageEditor.
func (*PicoChannel) Send ¶
func (c *PicoChannel) Send(ctx context.Context, msg bus.OutboundMessage) error
Send implements Channel — sends a message to the appropriate WebSocket connection.
func (*PicoChannel) SendPlaceholder ¶
SendPlaceholder implements channels.PlaceholderCapable. It sends a placeholder message via the Pico Protocol that will later be edited to the actual response via EditMessage (channels.MessageEditor).
func (*PicoChannel) ServeHTTP ¶
func (c *PicoChannel) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements http.Handler for the shared HTTP server.
func (*PicoChannel) Start ¶
func (c *PicoChannel) Start(ctx context.Context) error
Start implements Channel.
func (*PicoChannel) StartTyping ¶
func (c *PicoChannel) StartTyping(ctx context.Context, chatID string) (func(), error)
StartTyping implements channels.TypingCapable.
func (*PicoChannel) Stop ¶
func (c *PicoChannel) Stop(ctx context.Context) error
Stop implements Channel.
func (*PicoChannel) WebhookPath ¶
func (c *PicoChannel) WebhookPath() string
WebhookPath implements channels.WebhookHandler.
type PicoMessage ¶
type PicoMessage struct {
Type string `json:"type"`
ID string `json:"id,omitempty"`
SessionID string `json:"session_id,omitempty"`
Timestamp int64 `json:"timestamp,omitempty"`
Payload map[string]any `json:"payload,omitempty"`
}
PicoMessage is the wire format for all Pico Protocol messages.