@@ -145,6 +145,10 @@ func (p *Plugin) OnActivate() (retErr error) {
145
145
}()
146
146
}
147
147
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.
148
152
if rtcdURL := cfg .getRTCDURL (); rtcdURL != "" && p .licenseChecker .RTCDAllowed () {
149
153
rtcdManager , err := p .newRTCDClientManager (rtcdURL )
150
154
if err != nil {
@@ -186,15 +190,22 @@ func (p *Plugin) OnActivate() (retErr error) {
186
190
return err
187
191
}
188
192
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
+
189
199
p .rtcServer = rtcServer
190
200
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).
191
205
go p .wsWriter ()
192
206
}
193
207
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.
198
209
go p .clusterEventsHandler ()
199
210
200
211
p .LogDebug ("activated" , "ClusterID" , status .ClusterId )
0 commit comments