Added multiple client connections in go rutines
This commit is contained in:
26
main.go
26
main.go
@@ -1,6 +1,9 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"time"
|
||||
|
||||
appConfig "github.com/xmpploadtesting/config"
|
||||
xmppService "github.com/xmpploadtesting/services"
|
||||
)
|
||||
@@ -15,5 +18,26 @@ func main() {
|
||||
|
||||
// Send online presence stanza
|
||||
xmppServiceInstance := xmppService.Instance()
|
||||
xmppService.SendOnlinePresenceStanza(xmppServiceInstance.XMPPClients[0].Client, xmppServiceInstance.XMPPClients[0].Config.Jid)
|
||||
|
||||
for {
|
||||
|
||||
for _, xmppClient := range xmppServiceInstance.XMPPClients {
|
||||
|
||||
// Send online presence stanza in go rutines
|
||||
go func(xmppClient xmppService.XMPPClient) {
|
||||
log.Printf("online presence stanza FOR %v", xmppClient.Config.Jid)
|
||||
err := xmppService.SendOnlinePresenceStanza(xmppClient.Client, xmppClient.Config.Jid)
|
||||
|
||||
if err != nil {
|
||||
log.Printf("There was an error while sending online presence stanza %v", err)
|
||||
}
|
||||
|
||||
}(xmppClient)
|
||||
|
||||
}
|
||||
// Delay before sending another message
|
||||
time.Sleep(time.Duration(appConfig.AppConfig.GeneralOptions.DelayBetweenMassages))
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user