Skip to content

Commit

Permalink
Don't initialize RTC server when using external rtcd service (#910)
Browse files Browse the repository at this point in the history
  • Loading branch information
streamer45 authored Dec 2, 2024
1 parent a9c4e41 commit f92bbbd
Showing 1 changed file with 30 additions and 34 deletions.
64 changes: 30 additions & 34 deletions server/activate.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,50 +156,46 @@ func (p *Plugin) OnActivate() (retErr error) {
p.LogDebug("rtcd client manager initialized successfully")

p.rtcdManager = rtcdManager
} else {
rtcServerConfig := rtc.ServerConfig{
ICEAddressUDP: cfg.UDPServerAddress,
ICEAddressTCP: cfg.TCPServerAddress,
ICEPortUDP: *cfg.UDPServerPort,
ICEPortTCP: *cfg.TCPServerPort,
ICEHostOverride: cfg.ICEHostOverride,
ICEServers: rtc.ICEServers(cfg.getICEServers(false)),
TURNConfig: rtc.TURNConfig{
CredentialsExpirationMinutes: *cfg.TURNCredentialsExpirationMinutes,
},
EnableIPv6: *cfg.EnableIPv6,
}
if *cfg.ServerSideTURN {
rtcServerConfig.TURNConfig.StaticAuthSecret = cfg.TURNStaticAuthSecret
}
if cfg.ICEHostPortOverride != nil {
rtcServerConfig.ICEHostPortOverride = rtc.ICEHostPortOverride(fmt.Sprintf("%d", *cfg.ICEHostPortOverride))
}
rtcServer, err := rtc.NewServer(rtcServerConfig, newLogger(p), p.metrics.RTCMetrics())
if err != nil {
p.LogError(err.Error())
return err
}

go p.clusterEventsHandler()

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

return nil
}
if err := rtcServer.Start(); err != nil {
p.LogError(err.Error())
return err
}

rtcServerConfig := rtc.ServerConfig{
ICEAddressUDP: cfg.UDPServerAddress,
ICEAddressTCP: cfg.TCPServerAddress,
ICEPortUDP: *cfg.UDPServerPort,
ICEPortTCP: *cfg.TCPServerPort,
ICEHostOverride: cfg.ICEHostOverride,
ICEServers: rtc.ICEServers(cfg.getICEServers(false)),
TURNConfig: rtc.TURNConfig{
CredentialsExpirationMinutes: *cfg.TURNCredentialsExpirationMinutes,
},
EnableIPv6: *cfg.EnableIPv6,
}
if *cfg.ServerSideTURN {
rtcServerConfig.TURNConfig.StaticAuthSecret = cfg.TURNStaticAuthSecret
}
if cfg.ICEHostPortOverride != nil {
rtcServerConfig.ICEHostPortOverride = rtc.ICEHostPortOverride(fmt.Sprintf("%d", *cfg.ICEHostPortOverride))
}
rtcServer, err := rtc.NewServer(rtcServerConfig, newLogger(p), p.metrics.RTCMetrics())
if err != nil {
p.LogError(err.Error())
return err
}
p.rtcServer = rtcServer

if err := rtcServer.Start(); err != nil {
p.LogError(err.Error())
return err
go p.wsWriter()
}

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

go p.clusterEventsHandler()
go p.wsWriter()

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

Expand Down

0 comments on commit f92bbbd

Please sign in to comment.