Documentation
¶
Index ¶
- type RTC
- func (r *RTC) AddLocalCandidate(candidate webrtc.ICECandidateInit)
- func (r *RTC) Destroy()
- func (r *RTC) GetAllLocalCandidates() []webrtc.ICECandidateInit
- func (r *RTC) IsConnected() bool
- func (r *RTC) Log() zerolog.Logger
- func (r *RTC) SendControlBytes(b []byte) error
- func (r *RTC) SendControlData(pb proto.Message) error
- func (r *RTC) SendData(pb proto.Message) error
- func (r *RTC) SendDataBytes(b []byte) error
- type RTCMap
- type RequestICE
- type RequestSDP
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RTC ¶
type RTC struct {
Id string // the id of the connection (e.g. the client id)
Pc *webrtc.PeerConnection // the actual webRTC connection
Candidates []webrtc.ICECandidateInit // the **local** ICE candidates (that can be transmitted to the other peers)
CandidatesLock *sync.Mutex // to make sure ICE candidates can be managed concurrently
// Communication channels
ControlChannel *webrtc.DataChannel // the data channel used for the control protocol between server and client
DataChannel *webrtc.DataChannel // the data channel used to send debugging information and tuning state
TimestampOffset int64 // the timestamp offset to calculate the time difference between the client and the server
}
func (*RTC) AddLocalCandidate ¶
func (r *RTC) AddLocalCandidate(candidate webrtc.ICECandidateInit)
Add a local ICE candidate to the list of candidates fetched so far
func (*RTC) Destroy ¶
func (r *RTC) Destroy()
Destroy an RTC object and the underlying webRTC connection
func (*RTC) GetAllLocalCandidates ¶
func (r *RTC) GetAllLocalCandidates() []webrtc.ICECandidateInit
Get a copy of all local ICE candidates (concurrency-safe)
func (*RTC) IsConnected ¶
Utility function to check if the connection is still active
func (*RTC) Log ¶
Create an easy function to get a logger with the context and connection id already set
func (*RTC) SendControlBytes ¶
func (*RTC) SendControlData ¶ added in v1.2.0
Sending on the control channel
func (*RTC) SendDataBytes ¶ added in v1.2.0
type RTCMap ¶
type RTCMap struct {
// contains filtered or unexported fields
}
func (*RTCMap) ForEach ¶
Executes a function for each RTC connection in the map Because the RTCMap is read locked during execution, this is concurrency-safe
func (*RTCMap) UnsafeGetAll ¶
Returns a list of all RTC connections in the map. Locks when reading the map but returns a list of pointers. If you want to execute a function for each RTC connection, use ForEach instead.
type RequestICE ¶
type RequestICE struct {
Candidate webrtc.ICECandidateInit `json:"candidate"`
Id string `json:"id"` // to distinguish between clients
Timestamp int64 `json:"timestamp"` // timestamp of the sender
}
The data format used by connecting clients (and the car) to send ICE candidates to the server
type RequestSDP ¶
type RequestSDP struct {
Offer webrtc.SessionDescription `json:"offer"`
Id string `json:"id"` // to distinguish between clients
Timestamp int64 `json:"timestamp"` // timestamp of the sender
}
The data format used for SDP requests