wrtcconn

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2023 License: AGPL-3.0 Imports: 17 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidTURNServerAddr   = errors.New("invalid TURN server address")                            // The specified TURN server address is invalid
	ErrMissingTURNCredentials  = errors.New("missing TURN server credentials")                        // The specified TURN server is missing credentials
	ErrMissingForcedTURNServer = errors.New("TURN is forced, but no TURN server has been configured") // All connections must use TURN, but no TURN server has been configured
)
View Source
var (
	ErrAllNamesClaimed = errors.New("all available names have been claimed") // All specified usernames have already been claimed by other peers

)

Functions

This section is empty.

Types

type Adapter

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

NamedAdapter provides a connection service without name conflict prevention

func NewAdapter

func NewAdapter(
	signaler string,
	key string,
	ice []string,
	channels []string,
	config *AdapterConfig,
	ctx context.Context,
) *Adapter

NewAdapter creates the adapter

func (*Adapter) Accept

func (a *Adapter) Accept() chan *Peer

Accept returns a channel on which peers will be sent when they connect

func (*Adapter) Close

func (a *Adapter) Close() error

Close disconnects the adapter from the signaler

func (*Adapter) Open

func (a *Adapter) Open() (chan string, error)

Open connects the adapter to the signaler

type AdapterConfig

type AdapterConfig struct {
	Timeout             time.Duration // Time to wait before retrying to connect to the signaler
	ID                  string        // ID to claim without conflict resolution (default is UUID)
	ForceRelay          bool          // Whether to block P2P connections
	OnSignalerReconnect func()        // Handler to be called when the adapter has reconnected to the signaler
}

AdapterConfig configures the adapter

type NamedAdapter

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

NamedAdapter provides a connection service with name conflict prevention

func NewNamedAdapter

func NewNamedAdapter(
	signaler string,
	key string,
	ice []string,
	channels []string,
	config *NamedAdapterConfig,
	ctx context.Context,
) *NamedAdapter

NewNamedAdapter creates the adapter

func (*NamedAdapter) Accept

func (a *NamedAdapter) Accept() chan *Peer

Accept returns a channel on which peers will be sent when they connect

func (*NamedAdapter) Close

func (a *NamedAdapter) Close() error

Close disconnects the adapter from the signaler

func (*NamedAdapter) Err

func (a *NamedAdapter) Err() chan error

Err returns a channel on which all fatal errors will be sent

func (*NamedAdapter) Open

func (a *NamedAdapter) Open() (chan string, error)

Open connects the adapter to the signaler

type NamedAdapterConfig

type NamedAdapterConfig struct {
	*AdapterConfig
	IDChannel   string                                             // Channel to use for ID negotiation
	Names       []string                                           // Names to try and claim one of
	Kicks       time.Duration                                      // Time to wait for kicks before claiming names
	IsIDClaimed func(theirs map[string]struct{}, ours string) bool // Handler to be called when asked to compare own ID with an incoming greeting
}

NamedAdapterConfig configures the adapter

type Peer

type Peer struct {
	PeerID    string             // ID of the peer
	ChannelID string             // Channel on which the peer is connected to
	Conn      io.ReadWriteCloser // Underlying connection to send/receive on
}

Peer is a connected remote adapter

Jump to

Keyboard shortcuts

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