Added delay for messages

This commit is contained in:
2021-09-23 11:17:48 +02:00
parent f693a3c5bb
commit c04cee256f

View File

@@ -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