peer

package
v0.6.4 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrClosedByPeer = errors.New("closed by peer")

Functions

This section is empty.

Types

type Cond

type Cond struct {
	C chan struct{}
	// contains filtered or unexported fields
}

A Cond is a condition variable like sync.Cond, but using a channel so we can use select.

func NewCond

func NewCond() *Cond

NewCond creates a new condition variable.

func (*Cond) Do

func (c *Cond) Do(f func())

Do runs f if the condition hasn't been signaled yet. Afterwards it will be signaled.

func (*Cond) Signal

func (c *Cond) Signal()

Signal closes the condition variable channel.

func (*Cond) Wait

func (c *Cond) Wait()

Wait waits for the condition variable channel to close.

type Conn

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

Conn wraps an RTCPeerConnection so connections can be made and accepted.

func Open

func Open(keypair crypt.KeyPair, peerPublicKey crypt.Key, options ...signal.Option) (*Conn, error)

Open opens a new Connection.

func (*Conn) Accept

func (conn *Conn) Accept() (stream net.Conn, port int, err error)

Accept accepts a new connection over the datachannel.

func (*Conn) Close

func (conn *Conn) Close() error

Close closes the peer connection

func (*Conn) Open

func (conn *Conn) Open(port int) (stream net.Conn, err error)

Open opens a new connection over the datachannel.

type ContextReadCloser

type ContextReadCloser struct {
	context.Context
	io.ReadCloser
	// contains filtered or unexported fields
}

func (ContextReadCloser) Close

func (cr ContextReadCloser) Close() error

func (ContextReadCloser) Read

func (cr ContextReadCloser) Read(p []byte) (n int, err error)

func (ContextReadCloser) SetReadDeadline

func (cr ContextReadCloser) SetReadDeadline(t time.Time) error

type ContextWriteCloser

type ContextWriteCloser struct {
	context.Context
	io.WriteCloser
	// contains filtered or unexported fields
}

func (ContextWriteCloser) Close

func (cw ContextWriteCloser) Close() error

func (ContextWriteCloser) SetWriteDeadline

func (cw ContextWriteCloser) SetWriteDeadline(t time.Time) error

func (ContextWriteCloser) Write

func (cw ContextWriteCloser) Write(p []byte) (n int, err error)

type DataChannel

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

A DataChannel implements the net.Conn interface over a webrtc data channel

func WrapDataChannel

func WrapDataChannel(rtcDataChannel RTCDataChannel) (*DataChannel, error)

WrapDataChannel wraps an rtc data channel and implements the net.Conn interface

func (*DataChannel) Close

func (dc *DataChannel) Close() error

func (*DataChannel) LocalAddr

func (dc *DataChannel) LocalAddr() net.Addr

func (*DataChannel) Read

func (dc *DataChannel) Read(b []byte) (n int, err error)

func (*DataChannel) RemoteAddr

func (dc *DataChannel) RemoteAddr() net.Addr

func (*DataChannel) SetDeadline

func (dc *DataChannel) SetDeadline(t time.Time) error

func (*DataChannel) SetReadDeadline

func (dc *DataChannel) SetReadDeadline(t time.Time) error

func (*DataChannel) SetWriteDeadline

func (dc *DataChannel) SetWriteDeadline(t time.Time) error

func (*DataChannel) Write

func (dc *DataChannel) Write(b []byte) (n int, err error)

type DialOption

type DialOption (func(*dialConfig))

type Dispatcher

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

func NewDispatcher

func NewDispatcher(conn *Conn) *Dispatcher

func (*Dispatcher) Listen

func (d *Dispatcher) Listen(port int) net.Listener

type RTCDataChannel

type RTCDataChannel interface {
	Close() error
	Label() string
	OnClose(func())
	OnMessage(func([]byte))
	OnOpen(func())
	Send([]byte) error
}

An RTCDataChannel abstracts an RTCDataChannel

type RTCPeerConnection

type RTCPeerConnection interface {
	AddICECandidate(string) error
	Close() error
	CreateDataChannel(label string) (RTCDataChannel, error)
	OnDataChannel(func(dc RTCDataChannel))
	OnICECandidate(func(string))
	OnICEConnectionStateChange(func(string))
	CreateAnswer() (string, error)
	CreateOffer() (string, error)
	SetAnswer(answer string) error
	SetOffer(offer string) error
}

An RTCPeerConnection abstracts an RTCPeerConnection

func NewRTCPeerConnection

func NewRTCPeerConnection() (RTCPeerConnection, error)

type SignalMessage

type SignalMessage struct {
	SDP           string
	ICECandidates []string
}

Jump to

Keyboard shortcuts

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