1 out of 4 pings
[svn42.git] / go / r3-netstatus / main.go
index 66763ff..0bb8d0e 100644 (file)
@@ -120,7 +120,8 @@ func EventToXMPP(bot *r3xmppbot.XmppBot, events <- chan interface{}, xmpp_presen
                     xmpp_presence_events_chan <- present_status
                     last_buttonpress = 0
                 }
-                
+                // Try to XMPP Ping the server and if that fails, quit XMPPBot
+                if bot.PingServer(900) == false && bot.PingServer(900) == false && bot.PingServer(900) == false && bot.PingServer(900) == false{ return }
             case r3events.DoorProblemEvent:
                 xmpp_presence_events_chan <- r3xmppbot.XMPPMsgEvent{Msg: fmt.Sprintf("Door Problem: %s. SeverityLevel: %d (%s)",event.Problem, event.Severity, time.Unix(event.Ts,0).String()), DistributeLevel: r3xmppbot.R3OnlineOnlyInfo, RememberAsStatus: false}
         }
@@ -145,7 +146,7 @@ func RunXMPPBot(ps *pubsub.PubSub, zmqctx *zmq.Context) {
         } else {
             Syslog_.Printf("Error starting XMPP Bot: %s", xmpperr.Error())
         }
-        time.Sleep(5 * time.Second)
+        time.Sleep(10 * time.Second)
     }
 }
 
@@ -193,7 +194,7 @@ func main() {
     go RunXMPPBot(ps, zmqctx)
 
     // --- receive and distribute events ---
-    ticker := time.NewTicker(time.Duration(7) * time.Minute)
+    ticker := time.NewTicker(time.Duration(6) * time.Minute)
     for {
     select {
         case e := <-zmqsub.In():