From c04cee256f662437f6472310d649645c1904e1e6 Mon Sep 17 00:00:00 2001 From: "nedim.uka" Date: Thu, 23 Sep 2021 11:17:48 +0200 Subject: [PATCH] Added delay for messages --- services/xmppsService.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/services/xmppsService.go b/services/xmppsService.go index b32af9e..997f61d 100644 --- a/services/xmppsService.go +++ b/services/xmppsService.go @@ -117,6 +117,11 @@ func Init() { } go func() { + + statusMesageDelay := int64(rand.Intn(appConfig.AppConfig.GeneralOptions.StatusMessageDelay)) + log.Printf("DELAYING FOR: %v", statusMesageDelay*1000000000) + // Delay For two seccond to allow all clients to connect + time.Sleep(time.Duration(statusMesageDelay * 1000000000)) defer wg.Done() client, err := xmpp.NewClient(&xmppClient.Config, xmppService.Router, errorHandler) @@ -146,6 +151,12 @@ func Init() { // SendOnlinePresenceStanza - send online presence stnza with data, to server func SendOnlinePresenceStanza(client *xmpp.Client, jid string) error { + + statusMesageDelay := int64(rand.Intn(appConfig.AppConfig.GeneralOptions.StatusMessageDelay)) + log.Printf("DELAYING FOR: %v", statusMesageDelay*1000000000) + // Delay For two seccond to allow all clients to connect + time.Sleep(time.Duration(statusMesageDelay * 1000000000)) + onlinePresencePacket := stanza.NewPresence(stanza.Attrs{From: jid, Type: stanza.StanzaType(stanza.PresenceShowChat)}) onlinePresencePacket.Status = rolingStockPresenceMessage