Documentation
¶
Index ¶
- func DialSignaling(ctx context.Context, wsURL string, headers http.Header, dialer Dialer) (*websocket.Conn, error)
- func ReadSignaling(conn *websocket.Conn, route func(signaling.Message)) error
- func WriteSignaling(ctx context.Context, conn *websocket.Conn, message signaling.Message) error
- type Dialer
- type EventConnection
- type LiveNegotiation
- type SignalingWriter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DialSignaling ¶
func DialSignaling(ctx context.Context, wsURL string, headers http.Header, dialer Dialer) (*websocket.Conn, error)
DialSignaling opens a bounded signaling socket with an optional custom dialer.
func ReadSignaling ¶
ReadSignaling reads text frames until a transport or decoding error occurs.
Types ¶
type Dialer ¶
type Dialer interface {
DialContext(ctx context.Context, wsURL string, headers http.Header) (*websocket.Conn, *http.Response, error)
}
Dialer allows tests and callers to substitute a WebSocket transport.
type EventConnection ¶
type EventConnection struct {
// contains filtered or unexported fields
}
EventConnection owns the transport, read loop, and event queue.
func OpenEvents ¶
func OpenEvents(ctx context.Context, wsURL, token, hardwareID string) (*EventConnection, error)
OpenEvents connects the account event stream and starts its read loop.
func OpenEventsWithDialer ¶ added in v0.5.0
func OpenEventsWithDialer( ctx context.Context, wsURL, token, hardwareID string, dialer Dialer, ) (*EventConnection, error)
OpenEventsWithDialer connects the account event stream using the supplied dialer. A nil dialer uses Gorilla's default dialer with a bounded handshake timeout.
func (*EventConnection) Close ¶
func (ec *EventConnection) Close() error
Close closes the event connection.
func (*EventConnection) Receive ¶
func (ec *EventConnection) Receive() (map[string]interface{}, error)
Receive receives events in wire order before a terminal read error. Concurrent callers are serialized to preserve that ordering.
func (*EventConnection) ReceiveFrame ¶ added in v0.5.0
func (ec *EventConnection) ReceiveFrame() (generatedsignaling.AccountEventFrame, json.RawMessage, error)
ReceiveFrame returns the schema-generated event projection and its full raw payload.
type LiveNegotiation ¶
type LiveNegotiation struct {
SignalID string
RIID string
AnswerSDP string
ControlID string
Heartbeat time.Duration
}
LiveNegotiation contains the identities and timing returned by signaling.
func AwaitLiveAnswer ¶
func AwaitLiveAnswer( ctx context.Context, parentDone <-chan struct{}, parentErr func() error, events <-chan signaling.Message, deviceID int64, deadlineError func() error, ) (LiveNegotiation, error)
AwaitLiveAnswer pairs session_created with the SDP answer and validates their identities.
type SignalingWriter ¶
type SignalingWriter struct {
// contains filtered or unexported fields
}
SignalingWriter bounds outgoing frames and prioritizes close, heartbeat, and PTZ stop.
func NewSignalingWriter ¶
func NewSignalingWriter(
done <-chan struct{},
write func(context.Context, signaling.Message) error,
onFailure func(error),
) *SignalingWriter
NewSignalingWriter constructs a writer that stops when done closes.
func (*SignalingWriter) Finished ¶
func (w *SignalingWriter) Finished() <-chan struct{}
Finished closes after Run drains queued requests.
func (*SignalingWriter) Run ¶
func (w *SignalingWriter) Run()
Run services the writer queue until done closes.