待机功能基本实现

This commit is contained in:
2024-11-06 15:44:35 +08:00
parent 8e2bf7f59b
commit ab0678aa3b
14 changed files with 317 additions and 151 deletions

View File

@@ -96,7 +96,7 @@ func Run() {
}
// 构建语音合成对象
t := tts.New(ctx, config.C.Aliyun)
tts.DefaultTTS = tts.New(ctx, config.C.Aliyun)
// 构建继电器对象
//r, err := relay.New(config.C.Relay, func(msg string) {
@@ -117,10 +117,10 @@ func Run() {
middleware.PayloadJSON[schema.PlayModal](),
middleware.DeviceLock(device),
middleware.EmergencyStop(common.GlobalStopper),
middleware.SoundStart(t),
middleware.SoundStart(),
middleware.RelayMaster(nil),
middleware.TimeoutOver(config.C.Game.MaxTimeout),
middleware.TickerAction(t),
middleware.TickerAction(),
middleware.PlayBgm(),
func(c *leaf.Context) {
log.Println("接收到启动消息: ", string(c.Payload))
@@ -130,11 +130,11 @@ func Run() {
}
},
)
// 处理后台线程报文
router.RegisterHandler(topicPrefix+"bg",
middleware.PayloadJSON[schema.BackgroundModel](),
// 处理待机线程报文
router.RegisterHandler(topicPrefix+"wait",
middleware.PayloadJSON[schema.WaitModel](),
middleware.EmergencyStop(common.GlobalBgStopper),
routes.BackgroundAction,
routes.WaitAction,
)
// 处理指令
router.RegisterHandler(topicPrefix+"command", routes.Command(device))