Documentation
¶
Overview ¶
Package protocol implements Sweef's wire format: a length-prefixed, JSON-RPC-2.0 compatible framing that is deliberately close enough to the Chrome DevTools Protocol (CDP) that existing CDP clients can attach with minimal shimming, while staying tiny and streaming-friendly.
Frame layout (little-endian):
[4 bytes] magic 'S','W','E','F' [4 bytes] payload length (uint32, max 64 MiB) [N bytes] UTF-8 JSON payload (a JsonRpc Request/Response/Notification)
Index ¶
Constants ¶
const ( Magic = "SWF1" MaxFrameLen = 64 << 20 // 64 MiB hard cap keeps hostile peers from OOM-ing us )
Variables ¶
Functions ¶
Types ¶
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn wraps a bidirectional stream with mutexed writes so many goroutines (engine events, RPC replies, MCP notifications) can share one socket.
func NewConn ¶
func NewConn(rw io.ReadWriteCloser) *Conn
type Message ¶
type Message struct {
JSONRPC string `json:"jsonrpc"`
ID int64 `json:"id,omitempty"`
Method string `json:"method,omitempty"`
Params json.RawMessage `json:"params,omitempty"`
Result json.RawMessage `json:"result,omitempty"`
Error *RpcError `json:"error,omitempty"`
}
Message is one JsonRpc envelope. Either Method != "" (request/notification), or Result/Error != nil (response).