mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
webrtc: add 'wait' option to disable waiting for initial connection establishment
This commit is contained in:
parent
e2931907d1
commit
e3f10d8b24
2 changed files with 19 additions and 3 deletions
|
@ -7,6 +7,12 @@ allOf:
|
|||
format:
|
||||
$ref: ../format_spec.yaml
|
||||
|
||||
wait:
|
||||
type: boolean
|
||||
default: true
|
||||
description: |
|
||||
Suspend start-up of VILLASnode until the connection with the remote peer has been established.
|
||||
|
||||
session:
|
||||
type: string
|
||||
title: Session indentifier
|
||||
|
|
|
@ -41,6 +41,7 @@ var (
|
|||
Host: "villas.k8s.eonerc.rwth-aachen.de",
|
||||
Path: "/ws/signaling",
|
||||
},
|
||||
Wait: true,
|
||||
WebRTC: webrtc.Configuration{
|
||||
ICEServers: []webrtc.ICEServer{
|
||||
{
|
||||
|
@ -79,6 +80,8 @@ type Config struct {
|
|||
Server *url.URL
|
||||
Session string
|
||||
|
||||
Wait bool
|
||||
|
||||
WebRTC webrtc.Configuration
|
||||
}
|
||||
|
||||
|
@ -93,6 +96,7 @@ func (n *Node) Parse(c []byte) error {
|
|||
var cfg struct {
|
||||
Session *string `json:"session"`
|
||||
Server *string `json:"server,omitempty"`
|
||||
Wait *bool `json:"wait,omitemty"`
|
||||
Ice *struct {
|
||||
Servers []struct {
|
||||
URLs []string `json:"urls,omitempty"`
|
||||
|
@ -106,6 +110,10 @@ func (n *Node) Parse(c []byte) error {
|
|||
return fmt.Errorf("failed to unmarshal config: %w", err)
|
||||
}
|
||||
|
||||
if cfg.Wait != nil {
|
||||
n.Config.Wait = *cfg.Wait
|
||||
}
|
||||
|
||||
if cfg.Session == nil || *cfg.Session == "" {
|
||||
return errors.New("missing or invalid session name")
|
||||
} else {
|
||||
|
@ -153,9 +161,11 @@ func (n *Node) Start() error {
|
|||
n.DataChannelLock.Lock()
|
||||
defer n.DataChannelLock.Unlock()
|
||||
|
||||
n.Logger.Info("Waiting until datachannel is connected...")
|
||||
for n.DataChannel == nil {
|
||||
n.DataChannelConnected.Wait()
|
||||
if n.Config.Wait {
|
||||
n.Logger.Info("Waiting until datachannel is connected...")
|
||||
for n.DataChannel == nil {
|
||||
n.DataChannelConnected.Wait()
|
||||
}
|
||||
}
|
||||
|
||||
return n.BaseNode.Start()
|
||||
|
|
Loading…
Add table
Reference in a new issue