Documentation
¶
Index ¶
- Variables
- type Channel
- func (c *Channel) Close() error
- func (c *Channel) Closed() <-chan struct{}
- func (c *Channel) Flush(timeout time.Duration, now func() time.Time)
- func (c *Channel) Label() string
- func (c *Channel) OnFrames(ctx context.Context, handler protocol.FrameHandler, bufSize int) error
- func (c *Channel) Open() <-chan struct{}
- func (c *Channel) SendAbort(reason string) error
- func (c *Channel) SendAddPeerAnswer(peerID uint8, sdp string) error
- func (c *Channel) SendAddPeerOffer(peerID uint8, sdp string) error
- func (c *Channel) SendData(ctx context.Context, offset uint64, payload []byte) error
- func (c *Channel) SendEOF() error
- func (c *Channel) SendMetadata(meta protocol.Metadata) error
- func (c *Channel) SendTransferComplete() error
- type Config
- type Session
- func (s *Session) AcceptAnswer(encodedAnswer string) error
- func (s *Session) AcceptOffer(encodedOffer string) (string, error)
- func (s *Session) Close() error
- func (s *Session) CreateChannel(label string) (*Channel, error)
- func (s *Session) CreateConnection(onConnectionStateChange func(connectionState webrtc.ICEConnectionState)) error
- func (s *Session) IsICELite() bool
- func (s *Session) IsLoopbackOnly() bool
- func (s *Session) MakeOffer() (string, error)
- func (s *Session) OnChannel(handler func(*Channel))
Constants ¶
This section is empty.
Variables ¶
var ErrNoLocalDescription = errors.New("local description nil after ICE gathering")
ErrNoLocalDescription is returned when ICE gathering completes with no local description.
var ErrOnFramesAlreadyRunning = errors.New("OnFrames already running on this channel")
ErrOnFramesAlreadyRunning is returned by Channel.OnFrames when called more than once on the same Channel.
Functions ¶
This section is empty.
Types ¶
type Channel ¶ added in v0.2.0
type Channel struct {
// contains filtered or unexported fields
}
Channel is a framed wrapper over a pion DataChannel.
func (*Channel) Closed ¶ added in v0.2.0
func (c *Channel) Closed() <-chan struct{}
Closed returns a channel closed when the underlying DataChannel closes.
func (*Channel) OnFrames ¶ added in v0.2.0
func (c *Channel) OnFrames( ctx context.Context, handler protocol.FrameHandler, bufSize int, ) error
OnFrames runs the receive loop, dispatching every incoming frame to handler via protocol.Dispatch.
func (*Channel) Open ¶ added in v0.2.0
func (c *Channel) Open() <-chan struct{}
Open returns a channel closed when the underlying DataChannel opens.
func (*Channel) SendAbort ¶ added in v0.2.0
SendAbort sends an ABORT frame carrying a free-form reason string.
func (*Channel) SendAddPeerAnswer ¶ added in v0.2.0
SendAddPeerAnswer sends an ADD_PEER_ANSWER frame with peerID and the answer SDP.
func (*Channel) SendAddPeerOffer ¶ added in v0.2.0
SendAddPeerOffer sends an ADD_PEER_OFFER frame with peerID and the offer SDP.
func (*Channel) SendData ¶ added in v0.2.0
SendData encodes payload as a DATA frame, sends it, then waits for the outgoing buffer to drain below bufferThreshold before returning.
func (*Channel) SendMetadata ¶ added in v0.2.0
SendMetadata encodes meta and sends it as a METADATA frame.
func (*Channel) SendTransferComplete ¶ added in v0.2.0
SendTransferComplete sends a one-byte TRANSFER_COMPLETE frame.
type Config ¶ added in v0.2.0
type Config struct {
// STUNServers are the full ICE STUN URLs ("stun:host:port"). A nil
// or empty slice disables STUN entirely — the session will produce
// only host (and mDNS) candidates. Passed through to webrtc.ICEServer.URLs.
STUNServers []string
// LoopbackOnly pins ICE to loopback-only interfaces and drops STUN,
// so the session produces only host candidates on lo0. Intended for
// the in-process benchmark (just bench) — deterministic path, no
// network interface required.
LoopbackOnly bool
// DisableMDNS suppresses mDNS candidate gathering. When false (the
// zero value), the session advertises a `.local` hostname for its
// host candidates instead of a raw LAN IP, matching browser
// behavior. Ignored under LoopbackOnly.
DisableMDNS bool
// ICELite enables pion's ICE-Lite mode, which skips the connectivity-
// check loop.
//
// Test-only: it's only safe when both peers are ICE-lite
// on a guaranteed-routable path (e.g. loopback in-process).
//
// Production transfers must leave this false.
ICELite bool
}
Config describes the networking knobs for a PeerConnection-backed Session. A zero value is valid: no STUN, no loopback pinning, mDNS gathering on. The CLI layer is responsible for providing a default STUN server when one is wanted.
type Session ¶
type Session struct {
Done chan struct{}
NetworkStats *stats.Stats
// contains filtered or unexported fields
}
Session wraps a pion PeerConnection with lifecycle state.
func NewReceiver ¶ added in v0.2.0
NewReceiver creates a Session with pion's DetachDataChannels enabled. Callers must invoke DataChannel.Detach() in OnOpen and drive their own Read loop — OnMessage never fires once detach is on.
func (*Session) AcceptAnswer ¶ added in v0.2.0
AcceptAnswer sets the remote answer on a PeerConnection whose offer was already sent.
func (*Session) AcceptOffer ¶ added in v0.2.0
AcceptOffer sets the remote offer, creates an answer, and waits for ICE gathering.
func (*Session) Close ¶ added in v0.2.0
Close releases the PeerConnection. Safe before CreateConnection and idempotent.
func (*Session) CreateChannel ¶ added in v0.2.0
CreateChannel creates an outgoing DataChannel wrapped as a *Channel.
func (*Session) CreateConnection ¶
func (s *Session) CreateConnection( onConnectionStateChange func(connectionState webrtc.ICEConnectionState), ) error
CreateConnection prepares a WebRTC connection.
func (*Session) IsICELite ¶ added in v0.2.0
IsICELite reports whether the session was configured with ICELite.
func (*Session) IsLoopbackOnly ¶ added in v0.2.0
IsLoopbackOnly reports whether the session was configured with LoopbackOnly.