liuxiaolong
2021-02-05 7cf6b23c83e1c4efb8567a16ab2f401be4b6d1bf
add PublishNetTimeout
2个文件已修改
16 ■■■■■ 已修改文件
hbusc.go 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
micronode.go 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
hbusc.go
@@ -538,6 +538,14 @@
    return err
}
func (h *BHBus) PubTimeout(nodes []bhomebus.NetNode, msg *MsgInfo, timeout int) int {
    data,err := json.Marshal(*msg)
    if err == nil {
        return h.sockPub.sock.PubTimeout(nodes, msg.Topic, data, timeout)
    }
    return -1
}
//追加订阅的主题消息
func (h *BHBus) Sub(topics []string) {
    if topics != nil {
micronode.go
@@ -241,6 +241,14 @@
    return ms.handle.Pub(nodes, pi)
}
func (ms *MicroNode) PublishNetTimeout(nodes []bhomebus.NetNode, topic string, msg []byte, timeout int) int {
    pi := &MsgInfo{
        Topic: topic,
        Body: msg,
    }
    return ms.handle.PubTimeout(nodes, pi, timeout)
}
//订阅主题
func (ms *MicroNode) Subscribe(topics []string) {
    ms.handle.Sub(topics)