package routes

import (
	"game-driver/internal/common"
	"game-driver/leaf"
	"go.uber.org/zap"
)

func Command(d *common.Device) leaf.HandlerFunc {
	return func(c *leaf.Context) {
		cmd := string(c.Payload)
		switch cmd {
		case "stop":
			common.GlobalStopper.Stop()
		case "stop-bg":
			common.GlobalBgStopper.Stop()
		case "status":
			d.PublishStatus()
		default:
			zap.S().Infof("接收到无效指令: %s\n", cmd)
		}
	}
}
