From 021679b25d25b608380be9e50d09184a3f49eb62 Mon Sep 17 00:00:00 2001
From: liuxiaolong <736321739@qq.com>
Date: 星期三, 26 六月 2019 18:37:58 +0800
Subject: [PATCH] test faceSdkExtract

---
 service/FaceSdkService.go |   43 ++++++++++++++++++++++++++++++-------------
 1 files changed, 30 insertions(+), 13 deletions(-)

diff --git a/service/FaceSdkService.go b/service/FaceSdkService.go
index d1bd50f..bd23acf 100644
--- a/service/FaceSdkService.go
+++ b/service/FaceSdkService.go
@@ -1,33 +1,50 @@
 package service
 
 import (
+	"basic.com/pubsub/protomsg.git"
 	"basic.com/valib/deliver.git"
-	"github.com/gin-gonic/gin/internal/json"
+	"encoding/json"
+	"fmt"
+	"github.com/gogo/protobuf/proto"
 )
 
-type ImageSource struct {
-	Id string `json:"id"`
-	Data []byte `json:"data"`
-}
 const (
 	Url_Service_PUSH = "tcp:///tmp///webserver-2.ipc"
 	Url_Service_PULL = "tcp:///tmp///webserver-1.ipc"
 )
-var imgChan chan ImageSource
-func PushImgMsg(is ImageSource){
-	imgChan <- is
+var imgPushChan chan protomsg.Recvmsg
+
+func PushImgMsg(is protomsg.Recvmsg){
+	imgPushChan <- is
 }
 
+var resultMap map[string]protomsg.SdkMessage
+
+
 func InitService(){
-	imgChan = make(chan ImageSource)
-	client := deliver.NewClient(deliver.PushPull, Url_Service_PUSH)
+	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 := <- imgChan:
-			b, _ := json.Marshal(is)
-			client.Send(b)
+			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
+		}
 
 	}
 

--
Gitblit v1.8.0