From ad4f3dcedab29a690c5eedbb08ba1b393917db0b Mon Sep 17 00:00:00 2001
From: lichao <lichao@aiotlink.com>
Date: 星期三, 21 四月 2021 17:39:34 +0800
Subject: [PATCH] update go api.

---
 api/bhsgo/bhome_node.go |   42 ++++++++++++------------------------------
 1 files changed, 12 insertions(+), 30 deletions(-)

diff --git a/api/bhsgo/bhome_node.go b/api/bhsgo/bhome_node.go
index dcc8248..c5d4019 100644
--- a/api/bhsgo/bhome_node.go
+++ b/api/bhsgo/bhome_node.go
@@ -9,11 +9,10 @@
 
 import (
 	bh "bhshmq/proto/source/bhome_msg"
-	"fmt"
 	"unsafe"
 )
 
-func BHApiIn1Out1(bhfunc C.FBHApiIn1Out1, data []byte, reply *bh.MsgCommonReply, timeout_ms int) bool {
+func bhApiIn1Out1(bhfunc C.FBHApiIn1Out1, data []byte, reply *bh.MsgCommonReply, timeout_ms int) bool {
 	creply := unsafe.Pointer(nil)
 	creply_len := C.int(0)
 	defer C.BHFree(creply, creply_len)
@@ -27,22 +26,22 @@
 
 func Register(proc *bh.ProcInfo, reply *bh.MsgCommonReply, timeout_ms int) bool {
 	data, _ := proc.Marshal()
-	return BHApiIn1Out1(C.FBHApiIn1Out1(C.BHRegister), data, reply, timeout_ms)
+	return bhApiIn1Out1(C.FBHApiIn1Out1(C.BHRegister), data, reply, timeout_ms)
 }
 
 func RegisterTopics(topics *bh.MsgTopicList, reply *bh.MsgCommonReply, timeout_ms int) bool {
 	data, _ := topics.Marshal()
-	return BHApiIn1Out1(C.FBHApiIn1Out1(C.BHRegisterTopics), data, reply, timeout_ms)
+	return bhApiIn1Out1(C.FBHApiIn1Out1(C.BHRegisterTopics), data, reply, timeout_ms)
 }
 
 func Subscribe(topics *bh.MsgTopicList, reply *bh.MsgCommonReply, timeout_ms int) bool {
 	data, _ := topics.Marshal()
-	return BHApiIn1Out1(C.FBHApiIn1Out1(C.BHSubscribeTopics), data, reply, timeout_ms)
+	return bhApiIn1Out1(C.FBHApiIn1Out1(C.BHSubscribeTopics), data, reply, timeout_ms)
 }
 
-func Heartbeat(topics *bh.MsgTopicList, reply *bh.MsgCommonReply, timeout_ms int) bool {
+func Heartbeat(topics *bh.ProcInfo, reply *bh.MsgCommonReply, timeout_ms int) bool {
 	data, _ := topics.Marshal()
-	return BHApiIn1Out1(C.FBHApiIn1Out1(C.BHHeartbeat), data, reply, timeout_ms)
+	return bhApiIn1Out1(C.FBHApiIn1Out1(C.BHHeartbeat), data, reply, timeout_ms)
 }
 
 func HeartbeatEasy(timeout_ms int) bool {
@@ -133,24 +132,24 @@
 var cgoClientCB ClientCB
 var cgoSubDataCB SubDataCB
 
-//export CGoSubDataCallback
-func CGoSubDataCallback(cpid C.PCVoid, pid_len C.int, data C.PCVoid, data_len C.int) {
+//export cgoSubDataCallback
+func cgoSubDataCallback(cpid C.PCVoid, pid_len C.int, data C.PCVoid, data_len C.int) {
 	proc_id := string(C.GoBytes(unsafe.Pointer(cpid), pid_len))
 	msg := bh.MsgPublish{}
 	msg.Unmarshal(C.GoBytes(unsafe.Pointer(data), data_len))
 	cgoSubDataCB(&proc_id, &msg)
 }
 
-//export CGoServerCallback
-func CGoServerCallback(cpid C.PCVoid, pid_len C.int, data C.PCVoid, data_len C.int, src unsafe.Pointer) {
+//export cgoServerCallback
+func cgoServerCallback(cpid C.PCVoid, pid_len C.int, data C.PCVoid, data_len C.int, src unsafe.Pointer) {
 	proc_id := string(C.GoBytes(unsafe.Pointer(cpid), pid_len))
 	msg := bh.MsgRequestTopic{}
 	msg.Unmarshal(C.GoBytes(unsafe.Pointer(data), data_len))
 	cgoServerCB(src, &proc_id, &msg)
 }
 
-//export CGoClientCallback
-func CGoClientCallback(cpid C.PCVoid, pid_len C.int, msgid C.PCVoid, msgid_len C.int, data C.PCVoid, data_len C.int) {
+//export cgoClientCallback
+func cgoClientCallback(cpid C.PCVoid, pid_len C.int, msgid C.PCVoid, msgid_len C.int, data C.PCVoid, data_len C.int) {
 	proc_id := string(C.GoBytes(unsafe.Pointer(cpid), pid_len))
 	msg_id := C.GoBytes(unsafe.Pointer(msgid), msgid_len)
 	var msg bh.MsgRequestTopicReply
@@ -164,20 +163,3 @@
 	cgoSubDataCB = sub
 	C.CGoStartWorker()
 }
-
-/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// user code:
-
-func ServerCallback(src unsafe.Pointer, proc_id *string, req *bh.MsgRequestTopic) {
-	fmt.Println("user server cb called, request topic: " + string(req.Topic) + ", data:" + string(req.Data))
-	reply := bh.MsgRequestTopicReply{}
-	reply.Data = []byte("reply 1234")
-	SendReply(src, &reply)
-}
-
-func SubDataCallback(proc_id *string, pub *bh.MsgPublish) {
-	fmt.Println("user sub data cb called")
-}
-func ClientCallback(proc_id *string, msg_id *[]byte, reply *bh.MsgRequestTopicReply) {
-	fmt.Println("user client cb reply: " + string(reply.Data))
-}
\ No newline at end of file

--
Gitblit v1.8.0