| | |
| | | Topic: TOPIC_QUERYKEY, |
| | | Body: []byte(topic), |
| | | }) |
| | | h.printLog("marshal req err:", err) |
| | | if err != nil { |
| | | return nil, fmt.Errorf("marshal req err:%s", err.Error()) |
| | | } |
| | | var ret []bhomebus.Mesg |
| | | n := h.sockWorker.sock.SendandrecvTimeout(reqNetNode, reqD, &ret, h.conf.sendTimeOut) |
| | | h.printLog("getNetNodeByTopic ret n:", n) |
| | | if n > 0 { |
| | | var reply CommonReply |
| | | err = json.Unmarshal(ret[0].Data, &reply) |
| | | h.printLog("unmarshal err:", err) |
| | | if err != nil { |
| | | h.printLog("unmarshal err:", err) |
| | | return nil, err |
| | | } |
| | | h.printLog("reply.Status:", reply.Status) |
| | | |
| | | if reply.Status == REPLY_SUCCESS { |
| | | err = json.Unmarshal(reply.Body, &nodes) |
| | | h.printLog("unmarshal err:", err, "nodes:", nodes) |
| | | if err == nil { |
| | | return nodes, nil |
| | | } else { |
| | | h.printLog("unmarshal err:", err, "nodes:", nodes) |
| | | return nil, fmt.Errorf("unmarshal reply.Body err:%s", err.Error()) |
| | | } |
| | | } else { |
| | | h.printLog("reply.Status:", reply.Status) |
| | | return nil, fmt.Errorf("REPLY STATUS:%d", reply.Status) |
| | | } |
| | | } else { |
| | | h.printLog("getNetNodeByTopic ret n:", n) |
| | | return nil, fmt.Errorf("GetNetNodeByTopic n:%d", n) |
| | | } |
| | | } |