From 58d904a328c0d849769b483e901a0be9426b8209 Mon Sep 17 00:00:00 2001 From: liuxiaolong <liuxiaolong@aiotlink.com> Date: 星期二, 20 七月 2021 20:20:44 +0800 Subject: [PATCH] 调整Request C.BHFree的位置 --- api/bhsgo/bhome_node_test.go | 33 +++++++++++++++++++++++++++++---- 1 files changed, 29 insertions(+), 4 deletions(-) diff --git a/api/bhsgo/bhome_node_test.go b/api/bhsgo/bhome_node_test.go index 9f2b324..cd4bfb9 100644 --- a/api/bhsgo/bhome_node_test.go +++ b/api/bhsgo/bhome_node_test.go @@ -1,11 +1,12 @@ package bhsgo import ( - bh "bhshmq/proto/source/bhome_msg" "fmt" "testing" "time" "unsafe" + + bh "basic.com/valib/bhshmq.git/proto/source/bhome_msg" ) func ServerCallback(src unsafe.Pointer, proc_id *string, req *bh.MsgRequestTopic) { @@ -25,11 +26,25 @@ proc_id := "test_proc" proc := bh.ProcInfo{} proc.ProcId = []byte(proc_id) + fmt.Println("proc id: ", proc.ProcId) reply := bh.MsgCommonReply{} - - StartWorker(ClientCallback, ServerCallback, SubDataCallback) + defer Cleanup() r := Register(&proc, &reply, 1000) + if r { + fmt.Println("register ok") + } else { + fmt.Println("register failed") + return + } + r = Unregister(&proc, &reply, 1000) + if r { + fmt.Println("Unregister ok") + } else { + fmt.Println("Unregister failed") + } + + r = Register(&proc, &reply, 1000) if r { fmt.Println("register ok") } else { @@ -37,6 +52,8 @@ t.Log("register error") return } + + StartWorker(ClientCallback, ServerCallback, SubDataCallback) r = HeartbeatEasy(1000) if r { @@ -53,6 +70,7 @@ } else { fmt.Println("reg topics failed") } + req := bh.MsgRequestTopic{} time.Sleep(time.Second * 1) req.Topic = []byte("topic0") @@ -65,7 +83,14 @@ pid := "" rr := bh.MsgRequestTopicReply{} dest := bh.BHAddress{} - for i := 0; i < 10000; i++ { + + queryProc := bh.MsgQueryProc{} + queryReply := bh.MsgQueryProcReply{} + + QueryProcs(&dest, &queryProc, &queryReply, 3000) + fmt.Println("query result:", string(queryReply.ProcList[0].Proc.ProcId)) + + for i := 0; i < 10; i++ { if Request(&dest, &req, &pid, &rr, 3000) { fmt.Println("server:" + pid + ", reply:" + string(rr.Data)) } else { -- Gitblit v1.8.0