mirror of
https://github.com/pion/webrtc.git
synced 2025-10-05 15:16:52 +08:00

* Add locking around SCTP Assocation * Add locking around DataChannel * Add locking around port+global ICE Closes #46
29 lines
690 B
Go
29 lines
690 B
Go
package webrtc
|
|
|
|
import (
|
|
"sync"
|
|
|
|
"github.com/pions/webrtc/pkg/datachannel"
|
|
)
|
|
|
|
// RTCDataChannel represents a WebRTC DataChannel
|
|
// The RTCDataChannel interface represents a network channel
|
|
// which can be used for bidirectional peer-to-peer transfers of arbitrary data
|
|
type RTCDataChannel struct {
|
|
sync.RWMutex
|
|
|
|
Onmessage func(datachannel.Payload)
|
|
ID uint16
|
|
Label string
|
|
|
|
rtcPeerConnection *RTCPeerConnection
|
|
}
|
|
|
|
// Send sends the passed message to the DataChannel peer
|
|
func (r *RTCDataChannel) Send(p datachannel.Payload) error {
|
|
if err := r.rtcPeerConnection.networkManager.SendDataChannelMessage(p, r.ID); err != nil {
|
|
return &UnknownError{Err: err}
|
|
}
|
|
return nil
|
|
}
|