mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
webrtc: create unreliable/unordered data-channels by default
This commit is contained in:
parent
dce51b2d52
commit
c499b28473
3 changed files with 35 additions and 4 deletions
|
@ -13,6 +13,20 @@ allOf:
|
|||
description: |
|
||||
Suspend start-up of VILLASnode until the connection with the remote peer has been established.
|
||||
|
||||
ordered:
|
||||
type: boolean
|
||||
default: false
|
||||
description: |
|
||||
Indicates if data is allowed to be delivered out of order.
|
||||
The default value of false, does not make guarantees that data will be delivered in order.
|
||||
|
||||
max_retransmits:
|
||||
type: integer
|
||||
default: 0
|
||||
description: |
|
||||
Limit the number of times a channel will retransmit data if not successfully delivered.
|
||||
This value may be clamped if it exceeds the maximum value supported.
|
||||
|
||||
session:
|
||||
type: string
|
||||
title: Session identifier
|
||||
|
|
|
@ -42,6 +42,8 @@ var (
|
|||
Path: "/ws/signaling",
|
||||
},
|
||||
Wait: true,
|
||||
MaxRetransmits: 0,
|
||||
Ordered: false,
|
||||
WebRTC: webrtc.Configuration{
|
||||
ICEServers: []webrtc.ICEServer{
|
||||
{
|
||||
|
@ -81,6 +83,8 @@ type Config struct {
|
|||
Session string
|
||||
|
||||
Wait bool
|
||||
MaxRetransmits uint16
|
||||
Ordered bool
|
||||
|
||||
WebRTC webrtc.Configuration
|
||||
}
|
||||
|
@ -94,9 +98,11 @@ func NewNode() nodes.Node {
|
|||
func (n *Node) Parse(c []byte) error {
|
||||
var err error
|
||||
var cfg struct {
|
||||
Session *string `json:"session"`
|
||||
Server *string `json:"server,omitempty"`
|
||||
Wait *bool `json:"wait,omitemty"`
|
||||
Session *string `json:"session"`
|
||||
Server *string `json:"server,omitempty"`
|
||||
Wait *bool `json:"wait,omitemty"`
|
||||
MaxRetransmits *uint16 `json:"max_retransmits,omitempty"`
|
||||
Ordered *bool `json:"ordered,omitempty"`
|
||||
Ice *struct {
|
||||
Servers []struct {
|
||||
URLs []string `json:"urls,omitempty"`
|
||||
|
@ -114,6 +120,14 @@ func (n *Node) Parse(c []byte) error {
|
|||
n.Config.Wait = *cfg.Wait
|
||||
}
|
||||
|
||||
if cfg.Ordered != nil {
|
||||
n.Config.Ordered = *cfg.Ordered
|
||||
}
|
||||
|
||||
if cfg.MaxRetransmits != nil {
|
||||
n.Config.MaxRetransmits = *cfg.MaxRetransmits
|
||||
}
|
||||
|
||||
if cfg.Session == nil || *cfg.Session == "" {
|
||||
return errors.New("missing or invalid session name")
|
||||
} else {
|
||||
|
|
|
@ -104,7 +104,10 @@ func (pc *PeerConnection) createPeerConnection() (*webrtc.PeerConnection, error)
|
|||
}
|
||||
|
||||
func (pc *PeerConnection) createDataChannel() (*webrtc.DataChannel, error) {
|
||||
dc, err := pc.CreateDataChannel("villas", nil)
|
||||
dc, err := pc.CreateDataChannel("villas", &webrtc.DataChannelInit{
|
||||
Ordered: &pc.config.Ordered,
|
||||
MaxRetransmits: &pc.config.MaxRetransmits,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create datachannel: %w", err)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue