Added delay for client status ok message

This commit is contained in:
2021-09-17 17:35:08 +02:00
parent 9964093b03
commit 73f8698ad7
4 changed files with 9 additions and 4 deletions

View File

@@ -6,6 +6,7 @@ import (
"fmt"
"io/ioutil"
"log"
"math/rand"
"os"
"strconv"
"time"
@@ -132,8 +133,8 @@ func Init() {
}()
}
// Delay For one seccond to allow all clients to connect
time.Sleep(time.Duration(1000000000))
// Delay For two seccond to allow all clients to connect
time.Sleep(time.Duration(2000000000))
}
@@ -188,8 +189,11 @@ func handleMessage(s xmpp.Sender, p stanza.Packet) {
}
log.Printf("<%v> received following message: %v", msg.To, msg.Body)
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))
// _, _ = fmt.Fprintf(os.Stdout, "Body = %s - from = %s\n", msg.Body, msg.From)
reply := stanza.Message{Attrs: stanza.Attrs{To: msg.From}, Body: `{"status": "OK"}`}
err := s.Send(reply)