From d5c8ff820385c55a82a153e6a7a6535f115dce2c Mon Sep 17 00:00:00 2001 From: liuxiaolong <liuxiaolong@aiotlink.com> Date: 星期一, 25 一月 2021 15:04:27 +0800 Subject: [PATCH] add RequestOnly --- hbusc.go | 13 +++++++++++++ 1 files changed, 13 insertions(+), 0 deletions(-) diff --git a/hbusc.go b/hbusc.go index 8608efb..e5f7dd6 100644 --- a/hbusc.go +++ b/hbusc.go @@ -452,6 +452,19 @@ return nil, fmt.Errorf("request err") } +func (h *BHBus) RequestOnly(rData []byte, rNodes []bhomebus.NetNode) ([]byte, error) { + var ret []bhomebus.Mesg + + n := h.sockWorker.sock.SendandrecvTimeout(rNodes, rData, &ret, h.conf.sendTimeOut) + + if n > 0 && len(ret) > 0 { + return ret[0].Data, nil + } else { + h.printLog("Request n: ", n, " len(ret): ", len(ret)) + } + return nil, fmt.Errorf("request err") +} + func (h *BHBus) Reply(replyKey int, i *Reply) error { data,err := json.Marshal(*i) if err != nil { -- Gitblit v1.8.0