龙赣华
2019-06-01 30ddb8de1ca12e4dc31db2a82e36f7429ee2d7c6
modify string to []byte
1个文件已修改
17 ■■■■■ 已修改文件
server.go 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server.go
@@ -2,7 +2,6 @@
import (
    "log"
    "strings"
    "time"
    "golang.org/x/net/context"
@@ -59,7 +58,7 @@
    ctx  context.Context
    sock mangos.Socket
    publishCh chan []string
    publishCh chan []byte
}
func Server(urlServer string, urlPubSub string, opt Options) (*DiscoveryServer, error) {
@@ -155,8 +154,6 @@
                d.services.Add(responses)
                return
            }
            //fmt.Println(" err: ",err.Error())
            //log.Println("DiscoveryServer: Error reading SURVEY responses", err.Error())
        } else {
            responses.Add(string(msg))
        }
@@ -184,14 +181,14 @@
        url:  url,
        sock: sock,
        publishCh: make(chan []string),
        publishCh: make(chan []byte),
    }
    go publiser.run()
    return publiser, nil
}
func (p *Publisher) Publish(msg []string) {
func (p *Publisher) Publish(msg []byte) {
    p.publishCh <- msg
}
@@ -202,7 +199,7 @@
            close(p.publishCh)
            return
        case msg := <-p.publishCh:
            err := p.sock.Send([]byte(strings.Join(msg, "|")))
            err := p.sock.Send(msg)
            if err != nil {
                log.Println("DiscoveryServer: Error PUBLISHING changes to the socket", err.Error())
            }
@@ -233,6 +230,6 @@
    //s.publisher.Publish(s.nodes.ToSlice())//publish nodes changed
}
func (d *DiscoveryServer) PublishMsg(msg string){
    d.services.publisher.Publish([]string{msg})
}
func (d *DiscoveryServer) PublishMsg(msg string) {
    d.services.publisher.Publish([]byte(msg))
}