Skip to content

Commit 4023963

Browse files
authored
Leave nodeID empty when using RTCD service (#912) (#915)
1 parent f92bbbd commit 4023963

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

server/activate.go

+15-4
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,10 @@ func (p *Plugin) OnActivate() (retErr error) {
145145
}()
146146
}
147147

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

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

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

194-
p.mut.Lock()
195-
p.nodeID = status.ClusterId
196-
p.mut.Unlock()
197-
208+
// Cluster events need to be handled regardless of whether the embedded RTC service or RTCD are in use.
198209
go p.clusterEventsHandler()
199210

200211
p.LogDebug("activated", "ClusterID", status.ClusterId)

0 commit comments

Comments
 (0)