package service import ( "basic.com/pubsub/protomsg.git" "basic.com/valib/deliver.git" "encoding/json" "fmt" "github.com/gogo/protobuf/proto" ) const ( Url_Service_PUSH = "tcp:///tmp///webserver-2.ipc" Url_Service_PULL = "tcp:///tmp///webserver-1.ipc" ) var imgPushChan chan protomsg.Recvmsg func PushImgMsg(is protomsg.Recvmsg){ imgPushChan <- is } var resultMap map[string]protomsg.SdkMessage func InitService(){ imgPushChan = make(chan protomsg.Recvmsg) client_push := deliver.NewClient(deliver.PushPull, Url_Service_PUSH) client_pull := deliver.NewClient(deliver.PushPull, Url_Service_PULL) for { select { case is := <- imgPushChan: b, _ := json.Marshal(is) client_push.Send(b) } } //接收人脸提取结果 for { resultBytes, err := client_pull.Recv() if err !=nil{ fmt.Println("pull err:",err) continue } rMsg := protomsg.SdkMessage{} if err := proto.Unmarshal(resultBytes, &rMsg);err !=nil{ fmt.Println(rMsg) resultMap[rMsg.Cid] = rMsg } } }