package test import ( "go-tcpFramework-rudy/tools/mq" "qiniupkg.com/x/log.v7" "testing" "time" ) func Callback(key string,msg string) { log.Print(key,msg) } func TestMq(t *testing.T) { cli := mq.RedisMqClient{} e := cli.Connect("49.235.25.67:16379",0,"") if nil != e{ log.Print(e.Error()) t.Error(e) } cli.Subscribe("msg",Callback) cli.Public("msg","shit") cli.Public("msg","shit2") cli.Public("msg","shit3") mqcli := mq.MqttClient{} e = mqcli.Connect("tcp://" + "49.235.25.67:1883",0,"122") log.Print(e) e = mqcli.Subscribe("/dev",Callback) log.Print(e) mqcli.Public("/dev","shit") for true{ time.Sleep(100) } }