diff --git a/mq.go b/mq.go index 9b9222b..1b92e32 100644 --- a/mq.go +++ b/mq.go @@ -52,6 +52,7 @@ func MQSendMsgWorker(id int, msgs <-chan ChatWarsMessage) { } func MQReceiveMsgWorker(id int, cmd chan<- ChatWarsCommand) { + var c ChatWarsCommand conn, err := amqp.Dial("amqp://" + cfg.Rabbit.User + ":" + cfg.Rabbit.Password + "@" + cfg.Rabbit.Host + "/" + cfg.Rabbit.ReceiveQueue) failOnError(err, "MQReceiveMsgWorker["+strconv.Itoa(id)+"] : Failed to connect to RabbitMQ") defer conn.Close() @@ -83,10 +84,10 @@ func MQReceiveMsgWorker(id int, cmd chan<- ChatWarsCommand) { for d := range m { // log.Printf("MQReceiveMsgWorker["+strconv.Itoa(id)+"] : Received a message: %s", string(d.Body)) - err = json.Unmarshal(d.Body, &x) + err = json.Unmarshal(d.Body, &c) logOnError(err, "MQReceiveMsgWorker["+strconv.Itoa(id)+"] : Can't unmarshal.\n"+string(d.Body)) if err == nil { - cmd <- x + cmd <- c } }