| | |
| | | "encoding/json" |
| | | "fmt" |
| | | "github.com/gogo/protobuf/proto" |
| | | "github.com/satori/go.uuid" |
| | | "io/ioutil" |
| | | "time" |
| | | ) |
| | | |
| | | const ( |
| | |
| | | Url_Service_PULL = "tcp:///tmp///webserver-1.ipc" |
| | | ) |
| | | var imgPushChan chan protomsg.Recvmsg |
| | | |
| | | func TestPushImgMsg() { |
| | | InitService() |
| | | imgData := readImgFile() |
| | | for { |
| | | PushImgMsg(protomsg.Recvmsg{ |
| | | Id:uuid.NewV4().String(), |
| | | Addr:"", |
| | | Picdata:imgData, |
| | | }) |
| | | |
| | | time.Sleep(5*time.Second) |
| | | } |
| | | } |
| | | |
| | | func readImgFile() []byte{ |
| | | filePath := "/home/user/workspace/timg.jpg" |
| | | bytes, _ := ioutil.ReadFile(filePath) |
| | | return bytes |
| | | } |
| | | |
| | | func PushImgMsg(is protomsg.Recvmsg){ |
| | | imgPushChan <- is |
| | |
| | | } |
| | | rMsg := protomsg.SdkMessage{} |
| | | if err := proto.Unmarshal(resultBytes, &rMsg);err !=nil{ |
| | | fmt.Println(rMsg) |
| | | fmt.Println("recv MSG:",rMsg) |
| | | resultMap[rMsg.Cid] = rMsg |
| | | } |
| | | |