liuxiaolong
2021-07-01 b9b16b451361341b990d3bbb78fc2d53b74202a0
add SubscribeNet
2个文件已修改
27 ■■■■ 已修改文件
hbusc.go 26 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
message.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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
}
message.go
@@ -64,6 +64,7 @@
    Channel            []string `json:"channel"`    // 新增频道,对应一个新的共享内存队列
    PubTopic           []string `json:"pubTopic"`   // 进程对外发布的服务主题
    SubTopic           []string `json:"subTopic"`   // 进程订阅的服务主题
    SubNetTopic     []string `json:"subNetTopic"`// 订阅全网主题消息,集群内其他节点发布此topic消息,则订阅者可跨机收到
}