基本逻辑完成
This commit is contained in:
21
internal/routes/command.go
Normal file
21
internal/routes/command.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package routes
|
||||
|
||||
import (
|
||||
"game-driver/internal/common"
|
||||
"game-driver/leaf"
|
||||
"log"
|
||||
)
|
||||
|
||||
func Command(d *common.Device) leaf.HandlerFunc {
|
||||
return func(c *leaf.Context) {
|
||||
cmd := string(c.Payload)
|
||||
switch cmd {
|
||||
case "stop":
|
||||
common.GlobalStopper.Stop()
|
||||
case "status":
|
||||
d.PublishStatus()
|
||||
default:
|
||||
log.Printf("接收到无效指令: %s\n", cmd)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user