Skip to content

Commit

Permalink
Leave nodeID empty when using RTCD service (#912) (#915)
Browse files Browse the repository at this point in the history
  • Loading branch information
streamer45 authored Dec 4, 2024
1 parent f92bbbd commit 4023963
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions server/activate.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ func (p *Plugin) OnActivate() (retErr error) {
}()
}

// rtcServer and rtcdManager are mutually exclusive throughout the entire lifetime of the plugin.
// Which one is used is decided here, during activation.
// We first check if RTCD is configured and allowed by the license. If so
// we try to initialize its connection and fail to start the plugin if that errors.
if rtcdURL := cfg.getRTCDURL(); rtcdURL != "" && p.licenseChecker.RTCDAllowed() {
rtcdManager, err := p.newRTCDClientManager(rtcdURL)
if err != nil {
Expand Down Expand Up @@ -186,15 +190,22 @@ func (p *Plugin) OnActivate() (retErr error) {
return err
}

// NodeID is set only when using the embedded service (no RTCD) since it's used to track which node is hosting
// a call and coordinate between nodes they may own the WS connection for other sessions in that same call.
// When RTCD is in place, there isn't a node hosting a call since this task is completely delegated to the RTCD side.
// Hence, in that case this field should be left empty.
p.nodeID = status.ClusterId

p.rtcServer = rtcServer

// The wsWriter routine is only necessary when running the embedded RTC server since
// it's a listener on rtcServer.ReceiveCh used to forward RTC messages (e.g. signaling)
// back to the client through the WS connection. The RTCD handler has a separate way to
// do this (see clientReader method).
go p.wsWriter()
}

p.mut.Lock()
p.nodeID = status.ClusterId
p.mut.Unlock()

// Cluster events need to be handled regardless of whether the embedded RTC service or RTCD are in use.
go p.clusterEventsHandler()

p.LogDebug("activated", "ClusterID", status.ClusterId)
Expand Down

0 comments on commit 4023963

Please sign in to comment.