【tick 修改】

This commit is contained in:
weizhihong 2023-08-31 10:40:28 +08:00
parent bf2118e10e
commit a6f3a49d4d
1 changed files with 3 additions and 3 deletions

View File

@ -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)
}