zhangmeng
2024-02-05 a3df1ad41bce6d8d3094014c6e369072e594e7be
api/bhsgo/bhome_node.go
@@ -256,3 +256,30 @@
func Cleanup() {
   C.BHCleanup()
}
// ///////////////////////////////////////////////////
func Request2(dest_addr *bh.BHAddress, data []byte, proc_id *string, replyPtr *unsafe.Pointer, replyLen *int, timeout_ms int) bool {
   dest, _ := dest_addr.Marshal()
   cpid := unsafe.Pointer(nil)
   cpid_len := C.int(0)
   creply := unsafe.Pointer(nil)
   creply_len := C.int(0)
   r := C.BHRequest(getPtr(&dest), C.int(len(dest)), getPtr(&data), C.int(len(data)), &cpid, &cpid_len, &creply, &creply_len, C.int(timeout_ms)) > 0
   defer C.BHFree(cpid, cpid_len)
   if r {
      *proc_id = string(unsafeGetBytes(&cpid, int(cpid_len)))
      *replyPtr = creply
      *replyLen = int(creply_len)
   }
   return r
}
func CFree(p unsafe.Pointer, size int) {
   if p != nil {
      C.BHFree(p, C.int(size))
   }
}
func SendReply2(src unsafe.Pointer, data []byte) bool {
   return C.BHSendReply(src, getPtr(&data), C.int(len(data))) > 0
}