This commit is contained in:
shoopea 2019-06-28 13:03:32 +08:00
parent da7c548639
commit 8957a372d9
2 changed files with 5 additions and 7 deletions

View File

@ -9,12 +9,9 @@ import (
func clientKeepAlive(k, v interface{}) bool {
clt := v.(*MQKeepAlive)
if clt.Date.Add(3 * KeepAliveHeartBeatSeconds * time.Second).Before(time.Now()) {
msgs, err := clientsQueue[clt.UserID64].Channel.QueuePurge(clientsQueue[clt.UserID64].Queue.Name, false)
msgs, err := clientsQueue[clt.UserID64].MQChannel.QueuePurge(clientsQueue[clt.UserID64].Queue.Name, false)
logOnError(err, "clientKeepAlive : Channel.QueuePurge()")
err = clientsQueue[clt.UserID64].Channel.Close()
logOnError(err, "clientKeepAlive : Channel.Close()")
err = clientsQueue[clt.UserID64].Connection.Close()
logOnError(err, "clientKeepAlive : Connection.Close()")
clientsQueue[clt.UserID64].Close()
c := TGCommand{
Type: commandSendMsg,
ToUserID64: clt.UserID64,

5
mq.go
View File

@ -7,12 +7,13 @@ import (
)
func (s MQSession) Open() error {
var err error
if s.isConnected {
return errors.New("Session is already connected.")
}
if SLL == false {
s.MQConnection, err = amqp.Dial("amqp://" + Session.User + ":" + Session.Password + "@" + Session.Host + "/" + Session.Path)
if SSL == false {
s.MQConnection, err = amqp.Dial("amqp://" + s.User + ":" + s.Password + "@" + s.Host + "/" + s.Path)
} else {
return errors.New("SSL connection not implemented")
}