Added execute single online presence status message

This commit is contained in:
2021-09-27 19:23:30 +02:00
parent 7765cb32a9
commit f72b8c0da1
5 changed files with 73 additions and 23 deletions

27
main.go
View File

@@ -2,7 +2,6 @@ package main
import (
"log"
"time"
appConfig "bitbucket.org/outfrontmedia/rolling-stock-display-simulation-tool/config"
xmppService "bitbucket.org/outfrontmedia/rolling-stock-display-simulation-tool/services"
@@ -19,25 +18,13 @@ func main() {
// Send online presence stanza
xmppServiceInstance := xmppService.Instance()
for {
for _, xmppClient := range xmppServiceInstance.XMPPClients {
// Send online presence stanza in go rutines
go func(xmppClient xmppService.XMPPClient) {
err := xmppService.SendOnlinePresenceStanza(xmppClient.Client, xmppClient.Config.Jid)
if err != nil {
log.Printf("There was an error while sending online presence stanza %v", err)
return
}
}(xmppClient)
}
// Delay before sending another message
time.Sleep(time.Duration(appConfig.AppConfig.GeneralOptions.PresenceStatusDelay * 1000000000))
// Execute send online presence status message for every client and termintate program
if appConfig.AppConfig.GeneralOptions.ExecuteSingleStatusMessage {
xmppServiceInstance.ExecuteSingleStatusMessage()
log.Println("ExecuteSingleStatusMessage finished, online presente status message sent sucessfuly")
return
}
// Keep the servbie running
xmppServiceInstance.RunOnlinePresenceStatusIndefinetly()
}