add cluster

This commit is contained in:
zhouyuyan
2018-01-16 16:50:10 +08:00
parent 123bb7210f
commit 1d6f6a4a71
4 changed files with 103 additions and 69 deletions

View File

@@ -22,7 +22,6 @@ func (c *client) SendInfo() {
log.Error("send info message error, ", err)
return
}
// log.Info("send info success")
}
func (c *client) StartPing() {
@@ -36,12 +35,17 @@ func (c *client) StartPing() {
log.Error("ping error: ", err)
c.Close()
}
case _, ok := <-c.closed:
if !ok {
return
}
}
}
}
func (c *client) SendConnect() {
if c.status == Disconnected {
if c.status != Connected {
return
}
m := packets.NewControlPacket(packets.Connect).(*packets.ConnectPacket)
@@ -54,7 +58,7 @@ func (c *client) SendConnect() {
log.Error("send connect message error, ", err)
return
}
// log.Info("send connet success")
log.Info("send connect success")
}
func NewInfo(sid, url string, isforword bool) *packets.PublishPacket {
@@ -99,10 +103,13 @@ func (c *client) ProcessInfo(packet *packets.PublishPacket) {
return
}
b.mu.Lock()
exist := b.CheckRemoteExist(rid, rurl)
if !exist {
go b.connectRouter(rurl, rid)
b.connectRouter(rurl, rid)
}
b.mu.Unlock()
// log.Info("isforword: ", isForward)
if !isForward {
route := &route{