debug client revamping

This commit is contained in:
shoopea 2019-07-31 15:22:02 +08:00
parent 3e3a1ca376
commit 1102fd47a5
2 changed files with 9 additions and 9 deletions

1
def.go
View File

@ -26,6 +26,7 @@ type MQClient struct {
type ChirpClient struct {
HeartBeat time.Time `json:"heart_beat"`
Login string `json:"nickname"`
Active bool
TGUserID64 int64 `json:"tg_user_id"`
MQ MQClient `json:"mq_client"`

View File

@ -166,17 +166,16 @@ func MQKeepAliveWorker() {
} else if clt, ok := getLockedClient(x.TGUserID64, true); ok {
clt.HeartBeat = x.Date
if clt.Active {
log.Printf("MQKeepAliveWorker : Client %s already active.\n", x.Nickname)
log.Printf("MQKeepAliveWorker : Client %s already active.\n", clt.Login)
clt.Mux.Unlock()
} else {
log.Printf("MQKeepAliveWorker : Connecting to %s.\n", x.Nickname)
clt.MQ = MQClient{
User: cfg.Rabbit.User,
Password: cfg.Rabbit.Password,
Host: cfg.Rabbit.Host,
Path: x.Queue,
SSL: false,
}
clt.Login = x.Nickname
log.Printf("MQKeepAliveWorker : Connecting to %s.\n", clt.Login)
clt.MQ.User = cfg.Rabbit.User
clt.MQ.Password = cfg.Rabbit.Password
clt.MQ.Host = cfg.Rabbit.Host
clt.MQ.Path = x.Queue
clt.MQ.SSL = false
clt.MQ.Connection, err = amqp.Dial("amqp://" + clt.MQ.User + ":" + clt.MQ.Password + "@" + clt.MQ.Host + "/" + clt.MQ.Path)
logOnError(err, "MQKeepAliveWorker : Failed to connect to RabbitMQ")
if err != nil {