From 1d6c040dcb9a01648edc66d8c0006c8c9294a705 Mon Sep 17 00:00:00 2001
From: lichao <lichao@aiotlink.com>
Date: 星期四, 22 四月 2021 18:28:30 +0800
Subject: [PATCH] add mutex timeout limit; use atomic as refcount.
---
api/bhsgo/bhome_node_test.go | 20 ++++++++++++++++++--
1 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/api/bhsgo/bhome_node_test.go b/api/bhsgo/bhome_node_test.go
index d4f4278..b00b1fe 100644
--- a/api/bhsgo/bhome_node_test.go
+++ b/api/bhsgo/bhome_node_test.go
@@ -1,12 +1,26 @@
package bhsgo
import (
- bh "bhshmq/proto/source/bhome_msg"
+ bh "basic.com/valib/bhshmq.git/proto/source/bhome_msg"
"fmt"
"testing"
"time"
+ "unsafe"
)
+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))
+}
func TestRegister(t *testing.T) {
proc_id := "test_proc"
proc := bh.ProcInfo{}
@@ -20,6 +34,7 @@
fmt.Println("register ok")
} else {
fmt.Println("register failed")
+ t.Log("register error")
return
}
@@ -49,8 +64,9 @@
pid := ""
rr := bh.MsgRequestTopicReply{}
+ dest := bh.BHAddress{}
for i := 0; i < 10000; i++ {
- if Request(&req, &pid, &rr, 3000) {
+ if Request(&dest, &req, &pid, &rr, 3000) {
fmt.Println("server:" + pid + ", reply:" + string(rr.Data))
} else {
e, s := GetLastError()
--
Gitblit v1.8.0