liuxiaolong
2019-06-26 0f17a27a58f03de5d465fb5e9c03e768fa953d46
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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)
        }
 
 
    }
 
}