From b9b16b451361341b990d3bbb78fc2d53b74202a0 Mon Sep 17 00:00:00 2001 From: liuxiaolong <liuxiaolong@aiotlink.com> Date: 星期四, 01 七月 2021 17:00:09 +0800 Subject: [PATCH] add SubscribeNet --- hbusc.go | 26 +++++++++++++++++++++----- 1 files changed, 21 insertions(+), 5 deletions(-) diff --git a/hbusc.go b/hbusc.go index bf9cc94..62b2313 100644 --- a/hbusc.go +++ b/hbusc.go @@ -129,7 +129,7 @@ handle.wg = &sync.WaitGroup{} //鏈夎闃呮秷鎭墠闇�瑕佸惎鍔ㄥ崗绋嬫帴鏀舵秷鎭� - if ri.SubTopic != nil && len(ri.SubTopic) > 0 { + if len(ri.SubTopic) > 0 { handle.printLog("sub topics") var subList bhome_msg.MsgTopicList for _,v := range ri.SubTopic { @@ -137,13 +137,29 @@ } var subReply bhome_msg.MsgCommonReply - if bhsgo.Subscribe(&subList, &subReply, handle.conf.sendTimeOut) { - //鍚姩璁㈤槄淇℃伅鎺ユ敹 - handle.wg.Add(1) - go recvSubRoutine(ctx, handle.wg, handle.ChSub, handle.printLog) + if !bhsgo.Subscribe(&subList, &subReply, handle.conf.sendTimeOut) { + handle.printLog("bhsgo.Subscribe ret false") } } + if len(ri.SubNetTopic) > 0 { + handle.printLog("sub net topics") + var subNetList bhome_msg.MsgTopicList + for _,v := range ri.SubNetTopic { + subNetList.TopicList = append(subNetList.TopicList, []byte(v)) + } + var subNetReply bhome_msg.MsgCommonReply + if !bhsgo.SubscribeNet(&subNetList, &subNetReply, handle.conf.sendTimeOut) { + handle.printLog("bhsgo.SubscribeNet ret false") + } + } + + if len(ri.SubTopic) > 0 || len(ri.SubNetTopic) > 0 { + //鍚姩璁㈤槄淇℃伅鎺ユ敹 + handle.wg.Add(1) + go recvSubRoutine(ctx, handle.wg, handle.ChSub, handle.printLog) + } + return handle, nil } -- Gitblit v1.8.0