conn

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// DefaultSTUNServer is the default STUN server used when none are configured.
	DefaultSTUNServer = "stun:stun.l.google.com:19302"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	AgentID        string
	Signaling      signaling.SignalingClient
	PeerManager    *peer.Manager
	MsgHandler     func(ctx context.Context, env *envelope.Envelope)
	X25519PubKey   string
	OnSession      func(peerID, x25519 string) error
	ConnectionGate func(peerID string) bool // returns true to allow connection
	DefaultSTUNURL string                   // STUN server URL used when no ICE servers are configured
	Logger         *slog.Logger
}

Config holds configuration for the connection manager.

type Manager

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

Manager orchestrates P2P connections between agents. It consumes signaling messages, initiates and responds to WebRTC connections, and registers established connections with the PeerManager.

func New

func New(cfg Config) *Manager

New creates a new connection manager.

func (*Manager) Connect

func (m *Manager) Connect(ctx context.Context, peerID string) error

Connect initiates a P2P connection to a peer. It blocks until the connection is established or the context is cancelled/times out.

func (*Manager) Start

func (m *Manager) Start(ctx context.Context)

Start begins the signaling message consumption loop.

func (*Manager) Stop

func (m *Manager) Stop()

Stop stops the connection manager and cleans up pending connections.

Jump to

Keyboard shortcuts

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