Added execute single online presence status message
This commit is contained in:
27
main.go
27
main.go
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user