Documentation ¶
Index ¶
- Constants
- type Config
- type Conn
- func (c *Conn) Close() error
- func (*Conn) LocalAddr() net.Addr
- func (c *Conn) Read(p []byte) (int, error)
- func (*Conn) RemoteAddr() net.Addr
- func (c *Conn) SetDeadline(deadline time.Time) error
- func (c *Conn) SetReadDeadline(deadline time.Time) error
- func (c *Conn) SetWriteDeadline(deadline time.Time) error
- func (c *Conn) Write(p []byte) (int, error)
- type DTLSRole
- type DebugSignal
- type Dialer
- func (d *Dialer) Close() error
- func (d *Dialer) CreateOffer(ctx context.Context) error
- func (d *Dialer) Dial(label string) (net.Conn, error)
- func (d *Dialer) DialContext(ctx context.Context, label string) (net.Conn, error)
- func (d *Dialer) GetOffer() ([]byte, error)
- func (d *Dialer) SetAnswer(answer []byte) error
- type Listener
- type ListenerRunningStatus
- type NAT1To1IPs
- type PortRange
- type SignalMethod
Constants ¶
const ( MTU_DEFAULT = 1024 MAX_RECV_TIMEOUT_DEFAULT = time.Second * 10 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶ added in v0.2.0
type Config struct { // ListenerDTLSRole defines the DTLS role when Listening. // MUST be either DTLSRoleClient or DTLSRoleServer, as defined in RFC4347 // DTLSRoleClient will send the ClientHello and start the handshake. // DTLSRoleServer will wait for the ClientHello. ListenerDTLSRole DTLSRole /**** OPTIONAL FIELDS ****/ // SignalMethod offers the automatic signaling when establishing the DataChannel. SignalMethod SignalMethod // IPs includes a slice of IP addresses and one single ICE Candidate Type. // If set, will add these IPs as ICE Candidates IPs *NAT1To1IPs // PortRange is the range of ports to use for the DataChannel. PortRange *PortRange // UDPMux allows serving multiple DataChannels over the one or more pre-established UDP socket. UDPMux ice.UDPMux // CandidateNetworkTypes restricts ICE agent to gather // on only selected types of networks. CandidateNetworkTypes []webrtc.NetworkType // InterfaceFilter restricts ICE agent to gather ICE candidates // on only selected interfaces. InterfaceFilter func(interfaceName string) (allowed bool) }
Config is the configuration for the Dialer and Listener.
func (*Config) BuildSettingEngine ¶ added in v0.2.0
BuildSettingEngine builds a SettingEngine from the configuration.
func (*Config) NewDialer ¶ added in v0.2.0
NewDialer creates a new Dialer from the given configuration.
func (*Config) NewListener ¶ added in v0.2.0
NewListener creates a new Listener from the given configuration.
type Conn ¶ added in v0.2.0
type Conn struct {
// contains filtered or unexported fields
}
Conn is a net.Conn implementation for WebRTC DataChannels.
func (*Conn) LocalAddr ¶ added in v0.2.0
LocalAddr implements the net.Conn LocalAddr method.
It is hardcoded to return nil since WebRTC DataChannels are P2P and Local addresses are therefore trivial.
func (*Conn) RemoteAddr ¶ added in v0.2.0
RemoteAddr implements the net.Conn RemoteAddr method.
It is hardcoded to return nil since WebRTC DataChannels are P2P and Remote addresses are therefore trivial.
func (*Conn) SetDeadline ¶ added in v0.2.0
SetDeadline implements the net.Conn SetDeadline method. It sets both read and write deadlines in a single call.
See SetReadDeadline and SetWriteDeadline for the behavior of the deadlines.
func (*Conn) SetReadDeadline ¶ added in v0.2.0
SetReadDeadline sets the deadline for future Read calls.
A Read call will fail and return os.ErrDeadlineExceeded before attempting to read from the buffer if the deadline has passed. And a Read call will block till no later than the set read deadline.
func (*Conn) SetWriteDeadline ¶ added in v0.2.0
SetWriteDeadline sets the deadline for future Write calls.
A Write call will fail and return os.ErrDeadlineExceeded before attempting to write to the buffer if the deadline has passed. Otherwise the set write deadline will not affect the WriteTo call.
type DTLSRole ¶ added in v0.2.0
type DTLSRole = webrtc.DTLSRole
const ( // DTLSRoleAuto defines the DTLS role is determined based on // the resolved ICE role: the ICE controlled role acts as the DTLS // client and the ICE controlling role acts as the DTLS server. DTLSRoleAuto DTLSRole = iota + 1 // DTLSRoleClient defines the DTLS client role. DTLSRoleClient // DTLSRoleServer defines the DTLS server role. DTLSRoleServer )
From pion/webrtc
type DebugSignal ¶ added in v0.2.0
type DebugSignal struct {
// contains filtered or unexported fields
}
IOSignal implements a minimalistic signaling method. Offerer's writer should write to the answerer's reader and vice versa.
func NewDebugSignal ¶ added in v0.2.0
func NewDebugSignal(bufferSize int) *DebugSignal
NewDebugSignal creates a new DebugSignal.
func (*DebugSignal) Answer ¶ added in v0.2.0
func (ds *DebugSignal) Answer(answer []byte) error
Answer implements SignalMethod.Answer. It writes the SDP answer to answers channel.
func (*DebugSignal) GetAnswer ¶ added in v0.2.0
func (ds *DebugSignal) GetAnswer() ([]byte, error)
GetAnswer implements SignalMethod.GetAnswer It reads the SDP answer from answers channel.
func (*DebugSignal) GetOffer ¶ added in v0.2.0
func (ds *DebugSignal) GetOffer() ([]byte, error)
GetOffer implements SignalMethod.GetOffer It reads the SDP offer from offers channel.
func (*DebugSignal) MakeOffer ¶ added in v0.2.0
func (ds *DebugSignal) MakeOffer(offer []byte) error
MakeOffer implements SignalMethod.MakeOffer. It writes the SDP offer to offers channel.
type Dialer ¶ added in v0.2.0
type Dialer struct { SignalMethod SignalMethod MTU int // maximum transmission unit // contains filtered or unexported fields }
Dialer can dial a remote peer.
If the SignalMethod is set, the Offer/Answer exchange per new PeerConnection will be done automatically.
func (*Dialer) Close ¶ added in v0.2.0
Close closes the WebRTC PeerConnection and with it all the WebRTC DataChannels under it.
SHOULD be called when done using the transport.
func (*Dialer) CreateOffer ¶ added in v0.2.0
CreateOffer creates a local offer and sets it as the local description.
Automatically called by NewPeerConction when SignalMethod is set.
func (*Dialer) Dial ¶ added in v0.2.0
Dial connects to a remote peer with SDP-based negotiation.
Internally calls DialContext with context.Background().
The returned connection is backed by a DataChannel created by the caller with the SDP role as OFFERER as defined in RFC3264. If SignalMethod is set, the Offer/Answer exchange per new PeerConnection will be done automatically. Otherwise, it is recommended to call NewPeerConnection and exchange the SDP offer/answer manually before dialing.
func (*Dialer) DialContext ¶ added in v0.2.0
DialContext connects to a remote peer with SDP-based negotiation using the provided context.
The provided Context must be non-nil. If the context expires before the connection is complete, an error is returned. Once successfully connected, any expiration of the context will not affect the connection.
The returned connection is backed by a DataChannel created by the caller with the SDP role as OFFERER as defined in RFC3264. If SignalMethod is set, the Offer/Answer exchange per new PeerConnection will be done automatically. Otherwise, it is recommended to call NewPeerConnection and exchange the SDP offer/answer manually before dialing.
type Listener ¶ added in v0.2.0
type Listener struct { SignalMethod SignalMethod MTU int MaxAcceptTimeout time.Duration // contains filtered or unexported fields }
Listener listens for new PeerConnections and saves all incoming datachannel from peers for later use.
func (*Listener) Accept ¶ added in v0.2.0
Accept accepts a new connection from the listener.
It does not establish new connections. These connections are from the pool filled automatically by acceptLoop.
type ListenerRunningStatus ¶ added in v0.2.0
type ListenerRunningStatus = uint32
const ( LISTENER_NEW ListenerRunningStatus = iota LISTENER_RUNNING LISTENER_SUSPENDED LISTENER_STOPPED )
type NAT1To1IPs ¶ added in v0.2.0
type NAT1To1IPs struct { IPs []string Type webrtc.ICECandidateType }
NAT1To1IPs consists of a slice of IP addresses and one single ICE Candidate Type. Use this struct to set the IPs to be used as ICE Candidates.
type SignalMethod ¶ added in v0.2.0
type SignalMethod interface { // MakeOffer sends the SDP offer generated by offerer to the answerer. // // Called by OFFERER (#1) MakeOffer(offer []byte) error // GetOffer SHOULD return an error if Offer is not yet received/available. // However, blocking until an offer is received is also acceptable. // // Called by ANSWERER (#2) GetOffer() ([]byte, error) // Answer sends the SDP answer generated by answerer to the offerer. // // Called by ANSWERER (#3) Answer(answer []byte) error // GetAnswer blocks until the next SDP answer is available. // // Called by OFFERER (#4) GetAnswer() ([]byte, error) }
var ( // SignalMethodManual won't automatically establish a connection. // The connection will be established once both party have called SetRemoteDescription. SignalMethodManual SignalMethod = nil )