Websocket 实时拉取

This commit is contained in:
奶爸
2019-12-10 17:57:57 +08:00
parent be57af065d
commit 3c39e1537d
11 changed files with 197 additions and 32 deletions

View File

@@ -7,6 +7,7 @@ import (
"github.com/patrickmn/go-cache"
"github.com/p14yground/nezha/model"
pb "github.com/p14yground/nezha/proto"
)
// Conf ..
@@ -29,3 +30,19 @@ var ServerLock sync.RWMutex
// Version ..
var Version = "debug"
// SendCommand ..
func SendCommand(cmd *pb.Command) {
ServerLock.RLock()
defer ServerLock.RUnlock()
var err error
for _, server := range ServerList {
if server.Stream != nil {
err = server.Stream.Send(cmd)
if err != nil {
close(server.StreamClose)
server.Stream = nil
}
}
}
}