Handle properly stopping and starting the ping

Former-commit-id: 34c7717767
This commit is contained in:
Owen
2026-01-20 11:30:06 -08:00
parent 79e8a4a8bb
commit c4e297cc96
2 changed files with 34 additions and 7 deletions

View File

@@ -383,9 +383,9 @@ func (o *Olm) StartTunnel(config TunnelConfig) {
o.apiServer.SetConnectionStatus(true)
if o.connected {
logger.Debug("Already connected, skipping registration")
// Restart ping monitor on reconnect since the old one would have exited
o.websocket.StartPingMonitor()
logger.Debug("Already connected, skipping registration")
return nil
}
@@ -686,6 +686,14 @@ func (o *Olm) SetPowerMode(mode string) error {
logger.Info("Switching to low power mode")
// Mark as disconnected so we re-register on reconnect
o.connected = false
// Update API server connection status
if o.apiServer != nil {
o.apiServer.SetConnectionStatus(false)
}
if o.websocket != nil {
logger.Info("Disconnecting websocket for low power mode")
if err := o.websocket.Disconnect(); err != nil {