diff --git a/internal/server.go b/internal/server.go index 305dbf9..63078ec 100644 --- a/internal/server.go +++ b/internal/server.go @@ -108,16 +108,6 @@ func Run() { zap.S().Infof("未处理消息,topic: %s\n payload: %s\n", c.Topic, c.Payload) }) - // 构建 MQTT 连接 - mqttBuild := buildMqtt(config.C.Mqtt, router, topicPrefix+"#") - - // 连接 MQTT - cm, err := autopaho.NewConnection(ctx, mqttBuild) - if err != nil { - zap.S().Panicln("连接 MQTT 异常: ", err) - } - utils.GlobalMqttClient = cm - // 构建语音合成对象 tts.DefaultTTS = tts.New(ctx, config.C.Aliyun) @@ -165,6 +155,16 @@ func Run() { routes.Command(device), ) + // 构建 MQTT 连接 + mqttBuild := buildMqtt(config.C.Mqtt, router, topicPrefix+"#") + + // 连接 MQTT + cm, err := autopaho.NewConnection(ctx, mqttBuild) + if err != nil { + zap.S().Panicln("连接 MQTT 异常: ", err) + } + utils.GlobalMqttClient = cm + // 启动完成发送一次设备状态 device.PublishStatus() diff --git a/json.md b/json.md index c748d4a..47fbdd8 100644 --- a/json.md +++ b/json.md @@ -60,11 +60,8 @@ url: `server/wushan/5/play` "bgm": "file://./青云龙台.mp3", "power": true, "volume":1, - "tts": { - "start": "刘佳勇者,恭喜你成功通关!" - }, "game": { - "wait": 10 + "wait": 36 } } ```