lichao
2021-04-25 58e3540930d290b315fd24d0414c8feeb7bc8bc1
api/bhsgo/bhome_node.go
@@ -8,8 +8,9 @@
import "C"
import (
   bh "bhshmq/proto/source/bhome_msg"
   "unsafe"
   bh "basic.com/valib/bhshmq.git/proto/source/bhome_msg"
)
func getPtr(n *[]byte) unsafe.Pointer {
@@ -46,8 +47,8 @@
   return bhApiIn1Out1(C.FBHApiIn1Out1(C.BHSubscribeTopics), data, reply, timeout_ms)
}
func Heartbeat(topics *bh.ProcInfo, reply *bh.MsgCommonReply, timeout_ms int) bool {
   data, _ := topics.Marshal()
func Heartbeat(proc *bh.ProcInfo, reply *bh.MsgCommonReply, timeout_ms int) bool {
   data, _ := proc.Marshal()
   return bhApiIn1Out1(C.FBHApiIn1Out1(C.BHHeartbeat), data, reply, timeout_ms)
}
@@ -55,6 +56,24 @@
   return C.BHHeartbeatEasy(C.int(timeout_ms)) > 0
}
func Unregister(proc *bh.ProcInfo, reply *bh.MsgCommonReply, timeout_ms int) bool {
   data, _ := proc.Marshal()
   return bhApiIn1Out1(C.FBHApiIn1Out1(C.BHUnregister), data, reply, timeout_ms)
}
func QueryTopicAddress(topic *bh.MsgQueryTopic, reply *bh.MsgQueryTopicReply, timeout_ms int) bool {
   data, _ := topic.Marshal()
   creply := unsafe.Pointer(nil)
   creply_len := C.int(0)
   defer C.BHFree(creply, creply_len)
   r := C.BHQueryTopicAddress(getPtr(&data), C.int(len(data)), &creply, &creply_len, C.int(timeout_ms)) > 0
   if r {
      reply.Unmarshal(C.GoBytes(creply, creply_len))
   }
   return r
}
func Publish(pub *bh.MsgPublish, timeout_ms int) bool {
   data, _ := pub.Marshal()
   return C.BHPublish(getPtr(&data), C.int(len(data)), C.int(timeout_ms)) > 0