This commit is contained in:
yangduo 2024-09-13 17:28:08 +08:00
parent cee0dec313
commit 4d428b8e7d
2 changed files with 4 additions and 4 deletions

View File

@ -68,17 +68,17 @@ func (this *UDPListener) serverRead() {
retcode = 0 retcode = 0
} }
case "sub": case "sub":
if obj.Topic != "" && obj.Msg != "" { if obj.Topic != "" && obj.Channel != "" {
service.MqManager.SubscribeChannel(obj.Topic, obj.Channel) service.MqManager.SubscribeChannel(obj.Topic, obj.Channel)
retcode = 0 retcode = 0
} }
case "unsub": case "unsub":
if obj.Topic != "" && obj.Msg != "" { if obj.Topic != "" && obj.Channel != "" {
service.MqManager.UnsubscribeChannel(obj.Topic, obj.Channel) service.MqManager.UnsubscribeChannel(obj.Topic, obj.Channel)
retcode = 0 retcode = 0
} }
case "consume": case "consume":
if obj.Topic != "" && obj.Msg != "" { if obj.Topic != "" && obj.Channel != "" {
retcode = 0 retcode = 0
content = service.MqManager.ConsumeTopic(obj.Topic, obj.Channel) content = service.MqManager.ConsumeTopic(obj.Topic, obj.Channel)
} }

View File

@ -135,7 +135,7 @@ func (this *mqManager) ConsumeTopic(topic, channel string) (msg string) {
} }
} }
if msgidx > 0 { if msgidx > -1 {
msg = (*t).msgList[msgidx].content msg = (*t).msgList[msgidx].content
if del { if del {
if msgidx+1 < len((*t).msgList) { if msgidx+1 < len((*t).msgList) {