cotillartc

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2026 License: BSD-2-Clause Imports: 18 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const DefaultSTUNCSV = "stun:stun.l.google.com:19302,stun:stun.cloudflare.com:3478"

DefaultSTUNCSV is the comma-separated default STUN server list for CLI/config defaults.

Variables

View Source
var DefaultSTUNURLs = []string{
	"stun:stun.l.google.com:19302",
	"stun:stun.cloudflare.com:3478",
}

DefaultSTUNURLs are public STUN servers used for NAT traversal when no custom ICE servers are configured and STUN has not been explicitly disabled.

Functions

func ParseCSV added in v0.0.3

func ParseCSV(raw string) []string

ParseCSV splits a comma-separated list into trimmed non-empty entries.

Types

type ICEServer added in v0.0.3

type ICEServer struct {
	URLs       []string `json:"urls"`
	Username   string   `json:"username,omitempty"`
	Credential string   `json:"credential,omitempty"`
}

ICEServer describes a STUN or TURN server configuration compatible with both pion/webrtc and the browser RTCIceServer dictionary.

func CloneICEServers added in v0.0.3

func CloneICEServers(servers []ICEServer) []ICEServer

CloneICEServers returns a deep copy of servers, omitting empty entries.

func ParseICEServers added in v0.0.3

func ParseICEServers(stunCSV, turnCSV, turnUser, turnCred string) []ICEServer

ParseICEServers builds an ICEServer list from comma-separated STUN URLs and optional TURN URLs/credentials.

func STUNURLsToICEServers added in v0.0.3

func STUNURLsToICEServers(urls []string) []ICEServer

STUNURLsToICEServers wraps plain STUN/TURN URLs into an ICEServer slice.

type PionTransport

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

PionTransport is a DataChannel-only WebRTC transport running directly in the browser via syscall/js. It avoids linking pion/webrtc and its native network dependencies into the WebAssembly build.

func New

func New(self string, stunURLs []string, onData func(from string, data []byte)) *PionTransport

New creates a DataChannel-only WebRTC overlay transport for the local address self.

func (*PionTransport) AcceptAnswer

func (t *PionTransport) AcceptAnswer(peerAddr, answerSDP string) error

AcceptAnswer completes the handshake for an offered connection.

func (*PionTransport) AcceptOffer

func (t *PionTransport) AcceptOffer(peerAddr, offerSDP string) (string, error)

AcceptOffer handles an inbound offer from peerAddr and returns the local answer SDP.

func (*PionTransport) Broadcast

func (t *PionTransport) Broadcast(data []byte)

Broadcast delivers data to every open peer channel.

func (*PionTransport) Close

func (t *PionTransport) Close()

Close tears down all connections.

func (*PionTransport) ClosePeer

func (t *PionTransport) ClosePeer(addr string)

ClosePeer closes and cleans up an existing connection to addr.

func (*PionTransport) CreateOffer

func (t *PionTransport) CreateOffer(peerAddr string) (string, error)

CreateOffer starts a connection to peerAddr and returns the local SDP offer.

func (*PionTransport) HasActiveOrPending

func (t *PionTransport) HasActiveOrPending(addr string) bool

HasActiveOrPending returns true if addr currently has an open or in-progress connection.

func (*PionTransport) OnClose

func (t *PionTransport) OnClose(f func(addr string))

OnClose registers a callback fired when a peer's data channel or connection closes.

func (*PionTransport) OnOpen

func (t *PionTransport) OnOpen(f func(addr string))

OnOpen registers a callback fired when a peer's data channel opens.

func (*PionTransport) OnStateChange added in v0.0.6

func (t *PionTransport) OnStateChange(f func(addr string, state string))

OnStateChange registers a callback fired when a peer's RTCPeerConnection state changes (including "failed" before the DataChannel ever opens).

func (*PionTransport) PeerTransceiverCount

func (t *PionTransport) PeerTransceiverCount(addr string) int

PeerTransceiverCount returns the number of RTP transceivers on the connection to addr. Primary overlay connections are strictly DataChannel-only (0 transceivers).

func (*PionTransport) Peers

func (t *PionTransport) Peers() []string

Peers returns addresses with an open data channel.

func (*PionTransport) PendingLocalOffer added in v0.0.3

func (t *PionTransport) PendingLocalOffer(addr string) string

PendingLocalOffer returns the local SDP offer if addr currently has a pending outbound have-local-offer connection, allowing impolite glare handlers to re-transmit lost offers.

func (*PionTransport) Send

func (t *PionTransport) Send(addr string, data []byte) (err error)

Send delivers data to one peer over its data channel.

func (*PionTransport) SetICEServers added in v0.0.3

func (t *PionTransport) SetICEServers(servers []ICEServer)

SetICEServers updates the STUN/TURN servers used for subsequent browser RTCPeerConnections.

Jump to

Keyboard shortcuts

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