test
This commit is contained in:
parent
c94c8efd46
commit
0be25f0899
11
client.go
11
client.go
@ -2,27 +2,28 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func clientKeepAlive(k, v interface{}) bool {
|
func clientKeepAlive(k, v interface{}) bool {
|
||||||
c := v.(MQKeepAlive)
|
c := v.(MQKeepAlive)
|
||||||
if c.Date.Add(2 * KeepAliveHeartBeatSeconds * time.Second).Before(time.Now()) {
|
if c.Date.Add(2 * KeepAliveHeartBeatSeconds * time.Second).Before(time.Now()) {
|
||||||
msgs, err := clientsQueue[v.UserID64].Channel.QueuePurge(clientsQueue[v.UserID64].Queue.Name, false)
|
msgs, err := clientsQueue[c.UserID64].Channel.QueuePurge(clientsQueue[v.UserID64].Queue.Name, false)
|
||||||
logOnError(err, "clientKeepAlive : Channel.QueuePurge()")
|
logOnError(err, "clientKeepAlive : Channel.QueuePurge()")
|
||||||
err = clientsQueue[v.UserID64].Channel.Close()
|
err = clientsQueue[c.UserID64].Channel.Close()
|
||||||
logOnError(err, "clientKeepAlive : Channel.Close()")
|
logOnError(err, "clientKeepAlive : Channel.Close()")
|
||||||
err = clientsQueue[v.UserID64].Connection.Close()
|
err = clientsQueue[c.UserID64].Connection.Close()
|
||||||
logOnError(err, "clientKeepAlive : Connection.Close()")
|
logOnError(err, "clientKeepAlive : Connection.Close()")
|
||||||
c := TGCommand{
|
c := TGCommand{
|
||||||
Type: commandSendMsg,
|
Type: commandSendMsg,
|
||||||
ToUserID64: v.UserID64,
|
ToUserID64: c.UserID64,
|
||||||
Text: "Timeout, purging and closing command queue.",
|
Text: "Timeout, purging and closing command queue.",
|
||||||
}
|
}
|
||||||
TGCmdQueue <- c
|
TGCmdQueue <- c
|
||||||
c = TGCommand{
|
c = TGCommand{
|
||||||
Type: commandSendMsg,
|
Type: commandSendMsg,
|
||||||
ToUserID64: cfg.Bot.Admin,
|
ToUserID64: cfg.Bot.Admin,
|
||||||
Text: fmt.Sprintf("Client %s timed out (%d messages purged).", v.Nickname, msgs),
|
Text: fmt.Sprintf("Client %s timed out (%d messages purged).", c.Nickname, msgs),
|
||||||
}
|
}
|
||||||
TGCmdQueue <- c
|
TGCmdQueue <- c
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user