client

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_TIMEOUT               = 30 * time.Second
	DEFAULT_MAX_FRAME_SIZE        = 4 << 20
	DEFAULT_MAX_PENDING_ICE       = 128
	DEFAULT_MAX_PENDING_ICE_BYTES = 256 << 10
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func Dial

func Dial(roomID string, timeout time.Duration, adapter signaling.Adapter, psk peer.PreSharedKey, apiOptions ...peerapi.Option) (*Client, error)

Dial is the compact client entry point: callers provide a room, timeout, signaling adapter, and their pre-shared identity. No server/peer ID is part of the public API.

func NewClient

func NewClient(psk peer.PreSharedKey, api *api.API, options *Options) (*Client, error)

func (*Client) Close

func (c *Client) Close() error

func (*Client) Connect

func (c *Client) Connect() error

func (*Client) ConnectWithContext

func (c *Client) ConnectWithContext(ctx context.Context) error

func (*Client) Disconnect

func (c *Client) Disconnect() error

func (*Client) LocalAddr

func (c *Client) LocalAddr() net.Addr

func (*Client) Read

func (c *Client) Read(p []byte) (int, error)

Read reads received data from the buffer, blocking until data is available or the connection is closed (returns io.EOF).

func (*Client) Reconnect

func (c *Client) Reconnect() error

func (*Client) ReconnectWithContext

func (c *Client) ReconnectWithContext(ctx context.Context) error

func (*Client) RemoteAddr

func (c *Client) RemoteAddr() net.Addr

func (*Client) SetDeadline

func (c *Client) SetDeadline(t time.Time) error

func (*Client) SetReadDeadline

func (c *Client) SetReadDeadline(t time.Time) error

func (*Client) SetWriteDeadline

func (c *Client) SetWriteDeadline(t time.Time) error

func (*Client) Write

func (c *Client) Write(p []byte) (int, error)

type Options

type Options struct {
	// ICEAgentOptions are passed to the Pion ICE agent created for each connection.
	ICEAgentOptions []ice.AgentOption
	// TimeFunc returns the current time used to generate handshake timestamps.
	TimeFunc func() time.Time
	// Timeout is the maximum time to wait for a connection to be established.
	Timeout time.Duration
	// Transport selects the data transport negotiated after ICE. Nil defaults to
	// the raw UDP transport.
	Transport transports.ITransport
	// UseCompression enables zstd compression before encryption.
	UseCompression bool
	// MaxFrameSize is the maximum decoded encrypted transport frame size.
	MaxFrameSize int
	// ReceiveBufferSize is the maximum unread application data retained by Read.
	ReceiveBufferSize int
	// MaxPendingICE limits the number of ICE candidates buffered per connection.
	MaxPendingICE int
	// MaxPendingICEBytes limits the bytes used by buffered ICE candidates.
	MaxPendingICEBytes int
	// EncryptionAAD is additional authenticated data included in each frame.
	EncryptionAAD []byte
	// EncryptionType selects the frame cipher. Empty uses XChaCha20-Poly1305.
	EncryptionType string
	// OnClientHello is called after ClientHello is sent.
	OnClientHello func(*Client)
	// OnServerHello is called after a valid ServerHello is received.
	OnServerHello func(*Client)
	// OnICECandidate is called for each locally gathered ICE candidate.
	OnICECandidate func(*Client, ice.Candidate)
	// OnICECandidateGatheringComplete is called after local ICE candidate
	// gathering has completed.
	OnICECandidateGatheringComplete func(*Client)
	// OnICEOffer is called before the local ICE offer is published.
	OnICEOffer func(*Client, transports.ICEDescription)
	// OnICEAnswer is called after a valid ICE answer is received.
	OnICEAnswer func(*Client, transports.ICEDescription)
	// OnConnected is called after ICE and the selected transport are connected.
	OnConnected func(*Client)
	// OnConnectionFailed is called when connection establishment fails.
	OnConnectionFailed func(*Client, error)
	// OnDisconnected is called after an established connection is lost.
	OnDisconnected func(*Client)
}

Jump to

Keyboard shortcuts

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