Documentation
¶
Overview ¶
Package ssecommon provides common types and utilities for Server-Sent Events (SSE) used in communication between the client and MCP server.
Index ¶
Constants ¶
View Source
const ( // HTTPSSEEndpoint is the endpoint for SSE connections HTTPSSEEndpoint = "/sse" // HTTPMessagesEndpoint is the endpoint for JSON-RPC messages HTTPMessagesEndpoint = "/messages" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PendingSSEMessage ¶
type PendingSSEMessage struct {
// Message is the SSE message
Message *SSEMessage
// CreatedAt is the time the message was created
CreatedAt time.Time
}
PendingSSEMessage represents an SSE message that is pending delivery
func NewPendingSSEMessage ¶
func NewPendingSSEMessage(message *SSEMessage) *PendingSSEMessage
NewPendingSSEMessage creates a new pending SSE message
type SSEClient ¶
type SSEClient struct {
// MessageCh is the channel for sending messages to the client
MessageCh chan string
// CreatedAt is the time the client connected
CreatedAt time.Time
}
SSEClient represents a connected SSE client
type SSEMessage ¶
type SSEMessage struct {
// EventType is the type of event (e.g., "message", "endpoint")
EventType string
// Data is the event data
Data string
// TargetClientID is the ID of the target client (if any)
TargetClientID string
// CreatedAt is the time the message was created
CreatedAt time.Time
}
SSEMessage represents a Server-Sent Event message
func NewSSEMessage ¶
func NewSSEMessage(eventType, data string) *SSEMessage
NewSSEMessage creates a new SSE message
func (*SSEMessage) ToSSEString ¶
func (m *SSEMessage) ToSSEString() string
ToSSEString converts the message to an SSE-formatted string
func (*SSEMessage) WithTargetClientID ¶
func (m *SSEMessage) WithTargetClientID(clientID string) *SSEMessage
WithTargetClientID sets the target client ID for the message
Click to show internal directories.
Click to hide internal directories.