webrtc

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2019 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnswerStream

type AnswerStream interface {
	Next() (Signal, error)
	Close() error
}

AnswerStream is stream of responses to a discovery request.

type Local added in v0.2.3

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

Local represents an information about local peer.

func New added in v0.2.3

func New(uid string, s Signalling) *Local

New creates a new local peer with a given ID that will use a specific server for peer discovery.

func (*Local) Discover added in v0.2.3

func (l *Local) Discover() (Peers, error)

Discover starts an active peer discovery process by broadcasting a discovery request.

func (*Local) Listen added in v0.2.3

func (l *Local) Listen() (Peers, error)

Listen starts a passive peer discovery process by waiting for incoming discovery requests.

type Offer

type Offer interface {
	Info() Signal
	Answer(s Signal) error
}

Offer is a discovery message from a specific peer.

type OfferStream

type OfferStream interface {
	Next() (Offer, error)
	Close() error
}

OfferStream is a stream of discovery messages coming from other peers.

type Peer added in v0.2.3

type Peer interface {
	// UID returns a optional user ID of this peer.
	UID() string
	// Dial establishes a new connection to this peer.
	Dial() (net.Conn, error)
}

Peer represents an information about a potential peer.

type Peers added in v0.2.3

type Peers interface {
	// Accept queries an information about next available peer. It won't connect to it automatically.
	Accept() (Peer, error)
	// Close ends a peer discovery process.
	Close() error
}

Peers represents a dynamic list of peers that were discovered via signalling.

type Signal

type Signal struct {
	UID  string // optional user identifier to distinguish peers
	Data []byte // payload generated by WebRTC to establish connection
}

Signal describes a message that will be sent via signalling channel to discover peers.

type Signalling

type Signalling interface {
	// Broadcast sends a peer discovery request.
	Broadcast(s Signal) (AnswerStream, error)
	// Listen starts listening for incoming peer discovery requests.
	Listen(uid string) (OfferStream, error)
}

Signalling is an interface for a signalling connection that helps to establish P2P connections.

Jump to

Keyboard shortcuts

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