New file |
| | |
| | | package service |
| | | |
| | | import ( |
| | | "basic.com/valib/deliver.git" |
| | | "github.com/gin-gonic/gin/internal/json" |
| | | ) |
| | | |
| | | 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 |
| | | } |
| | | |
| | | func InitService(){ |
| | | imgChan = make(chan ImageSource) |
| | | client := deliver.NewClient(deliver.PushPull, Url_Service_PUSH) |
| | | for { |
| | | select { |
| | | case is := <- imgChan: |
| | | b, _ := json.Marshal(is) |
| | | client.Send(b) |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | } |