| | |
| | | "sync" |
| | | "time" |
| | | "unsafe" |
| | | |
| | | "github.com/bytedance/sonic" |
| | | ) |
| | | |
| | | type MsgReq struct { |
| | |
| | | if bhsgo.Request(&dest, req, &pid, &mrt, milliSecs) { |
| | | var reply Reply |
| | | if err := json.Unmarshal(mrt.Data, &reply); err != nil { |
| | | h.printLog("bhsgo.Request ret true, but unmarshal err:", err, " mrt.Data:", string(mrt.Data)) |
| | | return nil,err |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | func (h *BHBus) Reply(src unsafe.Pointer, i *Reply) error { |
| | | data,err := json.Marshal(*i) |
| | | defer func() { |
| | | i = nil |
| | | }() |
| | | |
| | | data,err := sonic.Marshal(i) |
| | | if err != nil { |
| | | return err |
| | | } |
| | | rep := bhome_msg.MsgRequestTopicReply{ |
| | | Data: data, |
| | | } |
| | | |
| | | if bhsgo.SendReply(src, &rep) { |
| | | return nil |
| | | } |