This commit is contained in:
2023-07-10 02:23:38 +08:00
parent 01b6451155
commit 66772cb659
6 changed files with 19 additions and 55 deletions

View File

@@ -139,7 +139,7 @@ func handleMessage(v Message) {
case "broadcast":
Hub.broadcast(rcmd[1], rcmd[2])
case "delay":
Hub.delay(rcmd, c)
Hub.Delay(rcmd)
case "timer":
for _, name := range rcmd[1:] {
Hub.timer([]string{"timer", name}, c) // append to timers

View File

@@ -125,7 +125,7 @@ func (s *ZSub) loadDelay() {
if exectime < time.Now().Unix() {
continue
}
s.delay([]string{"delay", split[0], split[1], strconv.FormatInt((exectime-time.Now().Unix())*1000, 10)}, nil)
s.Delay([]string{"delay", split[0], split[1], strconv.FormatInt((exectime-time.Now().Unix())*1000, 10)})
}
}

View File

@@ -28,8 +28,8 @@ type ZDelay struct {
Timer *time.Timer
}
// delay topic value 100 -> publish topic value
func (s *ZSub) delay(rcmd []string, c *ZConn) {
// Delay : delay topic value 100 -> publish topic value
func (s *ZSub) Delay(rcmd []string) {
s.Lock()
defer func() {
s.Unlock()
@@ -37,13 +37,13 @@ func (s *ZSub) delay(rcmd []string, c *ZConn) {
s.delayup = true
}()
if len(rcmd) != 4 {
c.send("-Error: subscribe para number!")
// c.send("-Error: subscribe para number!")
return
}
t, err := strconv.ParseInt(rcmd[3], 10, 64)
if err != nil {
c.send("-Error: " + strings.Join(rcmd, " "))
// c.send("-Error: " + strings.Join(rcmd, " "))
return
}