signaling

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: MPL-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const SubprotocolICE = "a2al.ice.v1"

SubprotocolICE is negotiated on the WebSocket used for ICE trickle signaling.

Variables

This section is empty.

Functions

func AppendQuery added in v0.1.4

func AppendQuery(rawURL, key, value string) (string, error)

AppendQuery sets or replaces a single query key on rawURL.

func AppendRoomQuery

func AppendRoomQuery(signalBase, room string) (string, error)

AppendRoomQuery adds or replaces the "room" query parameter on signalBase (absolute ws/wss URL).

func AppendRoomToICEURL added in v0.1.4

func AppendRoomToICEURL(signalBase, room string) (string, error)

AppendRoomToICEURL is ICERelayURL + AppendRoomQuery.

func DeriveSignalBaseFromHostPort added in v0.1.4

func DeriveSignalBaseFromHostPort(hostport string) (string, error)

DeriveSignalBaseFromHostPort builds ws:// or wss:// base (no path) from host:port.

func EncodeFrame

func EncodeFrame(f Frame) ([]byte, error)

EncodeFrame CBOR-encodes a frame.

func ICERelayURL added in v0.1.4

func ICERelayURL(signalBase string) (string, error)

ICERelayURL returns signalBase with path set to /ice.

func JoinURL

func JoinURL(relayBase, room string) (string, error)

JoinURL returns a full WebSocket URL including room query for a relay base.

func MustJoinURL

func MustJoinURL(relayBase, room string) string

MustJoinURL is JoinURL that panics on error (for tests with fixed inputs).

func RoomID

func RoomID(aidA, aidB string) string

RoomID is a deterministic 32-hex room name from two agent address strings (sorted).

func SubscribeURL added in v0.1.4

func SubscribeURL(signalBase string) (string, error)

SubscribeURL returns WebSocket URL for callee persistent registration (/signal).

Types

type Frame

type Frame struct {
	T      string `cbor:"t"`
	U      string `cbor:"u,omitempty"` // ufrag (cred)
	P      string `cbor:"p,omitempty"` // pwd (cred)
	C      string `cbor:"c,omitempty"` // ice candidate Marshal string
	AID    string `cbor:"a,omitempty"` // reg: callee AID; reserved for future use
	Sig    string `cbor:"s,omitempty"` // reg: reserved (AID squatting prevention)
	Room   string `cbor:"r,omitempty"` // incoming: room id
	Caller string `cbor:"f,omitempty"` // incoming: caller AID string
	Target string `cbor:"g,omitempty"` // incoming: callee AID (hub lookup key)
}

Frame is a CBOR envelope on the signaling WebSocket. T is "cred" | "cand" | "eoc" | "reg" | "incoming" | "noagent".

func DecodeFrame

func DecodeFrame(b []byte) (Frame, error)

DecodeFrame decodes a CBOR frame.

type Hub added in v0.1.4

type Hub struct {
	// contains filtered or unexported fields
}

Hub is an A2AL ICE signaling server: callee subscription on /signal and trickle relay on /ice (with optional target= for waking callees).

func ListenHub added in v0.1.4

func ListenHub(tcpAddr string) (*Hub, error)

ListenHub serves /signal and /ice on tcpAddr (e.g. "0.0.0.0:4121").

func (*Hub) Addr added in v0.1.4

func (h *Hub) Addr() net.Addr

Addr returns the bound TCP address.

func (*Hub) Close added in v0.1.4

func (h *Hub) Close() error

Close shuts down the hub listener.

func (*Hub) StatsMap added in v0.1.4

func (h *Hub) StatsMap() map[string]any

StatsMap returns counters for merging into /debug/stats.

type Relay

type Relay struct {
	// contains filtered or unexported fields
}

Relay is a minimal WebSocket relay: two clients joining the same ?room= are paired and their binary frames are forwarded bidirectionally. Intended for tests and small-scale deployments.

func StartRelay

func StartRelay(addr string) (*Relay, error)

StartRelay listens on addr (e.g. "127.0.0.1:0") and serves the relay.

func (*Relay) BaseURL

func (r *Relay) BaseURL() string

BaseURL returns ws://host:port (no trailing slash).

func (*Relay) Close

func (r *Relay) Close() error

Jump to

Keyboard shortcuts

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