protocol

package
v0.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 26, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FrameRegister     FrameType = "register"
	FrameRegisterAck  FrameType = "register_ack"
	FrameHeartbeat    FrameType = "heartbeat"
	FrameHeartbeatAck FrameType = "heartbeat_ack"
	FrameOpen         FrameType = "open"
	FrameOpenAck      FrameType = "open_ack"
	FrameClose        FrameType = "close"
	FrameError        FrameType = "error"
	FrameData         FrameType = "data"

	KindControl FrameKind = 1
	KindData    FrameKind = 2
)
View Source
const Version1 byte = 1

Variables

View Source
var (
	ErrFrameTooShort      = errors.New("frame too short")
	ErrUnsupportedVersion = errors.New("unsupported frame version")
	ErrInvalidFrameKind   = errors.New("invalid frame kind")
	ErrLengthMismatch     = errors.New("frame payload length mismatch")
)

Functions

func EncodeControl

func EncodeControl(f ControlFrame) ([]byte, error)

func EncodeControlFrame

func EncodeControlFrame(streamID uint64, frame ControlFrame) ([]byte, error)

func EncodeDataFrame

func EncodeDataFrame(streamID uint64, payload []byte) ([]byte, error)

func EncodeWireFrame

func EncodeWireFrame(frame WireFrame) ([]byte, error)

Types

type ControlFrame

type ControlFrame struct {
	Type              FrameType       `json:"type"`
	StreamID          uint64          `json:"stream_id,omitempty"`
	ClientID          string          `json:"client_id,omitempty"`
	Target            string          `json:"target,omitempty"`
	Message           string          `json:"message,omitempty"`
	SessionID         string          `json:"session_id,omitempty"`
	PreviousSessionID string          `json:"previous_session_id,omitempty"`
	Meta              json.RawMessage `json:"meta,omitempty"`
}

func DecodeControl

func DecodeControl(b []byte) (ControlFrame, error)

func DecodeControlFromWire

func DecodeControlFromWire(wf WireFrame) (ControlFrame, error)

type DataFrame

type DataFrame struct {
	StreamID uint64
	Payload  []byte
}

type FrameKind

type FrameKind byte

type FrameType

type FrameType string

type WireFrame

type WireFrame struct {
	Version  byte
	Kind     FrameKind
	StreamID uint64
	Payload  []byte
}

func DecodeWireFrame

func DecodeWireFrame(b []byte) (WireFrame, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL