Added execute single online presence status message
This commit is contained in:
@@ -223,6 +223,57 @@ func SendOnlinePresenceStanza(client *xmpp.Client, jid string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// RunOnlinePresenceStatusIndefinetly - keep sending online presence status messages indefinetly for all clients with delay
|
||||
func (xmppService *XMPPService) RunOnlinePresenceStatusIndefinetly() {
|
||||
|
||||
for {
|
||||
for _, xmppClient := range xmppService.XMPPClients {
|
||||
|
||||
// Send online presence stanza in go rutines
|
||||
go func(xmppClient XMPPClient) {
|
||||
err := 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))
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// ExecuteSingleStatusMessage - Wait for all clients to send online presence stanza messages just once
|
||||
func (xmppService *XMPPService) ExecuteSingleStatusMessage() {
|
||||
|
||||
var wg sync.WaitGroup
|
||||
|
||||
for _, xmppClient := range xmppService.XMPPClients {
|
||||
wg.Add(1)
|
||||
|
||||
// Send online presence stanza in go rutines
|
||||
go func(xmppClient XMPPClient) {
|
||||
defer wg.Done()
|
||||
err := SendOnlinePresenceStanza(xmppClient.Client, xmppClient.Config.Jid)
|
||||
|
||||
if err != nil {
|
||||
log.Printf("There was an error while sending online presence stanza %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
}(xmppClient)
|
||||
}
|
||||
|
||||
// Wait until all clients sent their online prezence staza messages
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
func getClientConfigsFromFile(filePath string) ([]ClientCredentials, error) {
|
||||
|
||||
var clientCredentials []ClientCredentials
|
||||
|
||||
Reference in New Issue
Block a user