liuxiaolong
2021-07-01 b9b16b451361341b990d3bbb78fc2d53b74202a0
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,11 +137,27 @@
      }
      var subReply bhome_msg.MsgCommonReply
      if bhsgo.Subscribe(&subList, &subReply, handle.conf.sendTimeOut) {
      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