diff --git a/grpcproto/message.go b/grpcproto/message.go index a1c4b3e..68abfbc 100644 --- a/grpcproto/message.go +++ b/grpcproto/message.go @@ -45,7 +45,7 @@ func RegisterMsgServer(server IMsgServer) { if server.getInterval() > 0 { exitChannel := make(chan bool) serverExitChannelMap[server.getChannelName()] = exitChannel - tick := time.Tick(server.getInterval()) + tick := time.NewTicker(server.getInterval()) go func() { defer func() { if r := recover(); r != nil { @@ -55,9 +55,9 @@ func RegisterMsgServer(server IMsgServer) { }() // 循环推送信息 for { - <-tick + <-tick.C topicMsgs := server.onTick() - if topicMsgs != nil && len(topicMsgs) != 0 { + if len(topicMsgs) != 0 { for _, msg := range topicMsgs { PublishMsg(msg.channalName, msg.data) }