| | |
| | | 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 { |
| | |
| | | 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) |