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
---
message.go | 1 +
hbusc.go | 26 +++++++++++++++++++++-----
2 files changed, 22 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
}
diff --git a/message.go b/message.go
index 9ce78da..4d66cf8 100644
--- a/message.go
+++ b/message.go
@@ -64,6 +64,7 @@
Channel []string `json:"channel"` // 鏂板棰戦亾锛屽搴斾竴涓柊鐨勫叡浜唴瀛橀槦鍒�
PubTopic []string `json:"pubTopic"` // 杩涚▼瀵瑰鍙戝竷鐨勬湇鍔′富棰�
SubTopic []string `json:"subTopic"` // 杩涚▼璁㈤槄鐨勬湇鍔′富棰�
+ SubNetTopic []string `json:"subNetTopic"`// 璁㈤槄鍏ㄧ綉涓婚娑堟伅,闆嗙兢鍐呭叾浠栬妭鐐瑰彂甯冩topic娑堟伅锛屽垯璁㈤槄鑰呭彲璺ㄦ満鏀跺埌
}
--
Gitblit v1.8.0