| | |
| | | // clientMsgCh[nodeId] = make(chan Message) |
| | | // } |
| | | //} |
| | | |
| | | if len(cacheNodes.Difference(nodeIds).ToSlice()) > 0 { //节点有变化的时候,也需要发消息 |
| | | fmt.Println("aliveNodes:",nodeIds) |
| | | if len(msgCache) > 0 { |
| | | for _,cMsg := range msgCache { |
| | | sendB, _ := json.Marshal(cMsg) |
| | | discoveryServer.PublishMsg(string(sendB)) |
| | | if len(nodeIds.ToSlice()) >0 { |
| | | if len(nodeIds.Difference(cacheNodes).ToSlice()) > 0 { //节点有变化的时候,也需要发消息 |
| | | fmt.Println("aliveNodes:",nodeIds) |
| | | if len(msgCache) > 0 { |
| | | for _,cMsg := range msgCache { |
| | | sendB, _ := json.Marshal(cMsg) |
| | | discoveryServer.PublishMsg(string(sendB)) |
| | | } |
| | | } |
| | | } |
| | | } else { |
| | | cacheNodes = discoveryServer.AliveNodes() |
| | | } else {//订阅者全部阵亡 |
| | | cacheNodes = discoveryServer.AliveNodes() |
| | | time.Sleep(10 * time.Millisecond) |
| | | } |
| | | cacheNodes = discoveryServer.AliveNodes() |
| | | } |
| | | } |
| | | }() |