实现缓存+mqtt设备消息监听
This commit is contained in:
@ -13,17 +13,10 @@ import (
|
||||
)
|
||||
|
||||
type sStoreDesktopSetting struct {
|
||||
mqttCLient mqtt.MqttClient
|
||||
}
|
||||
|
||||
func New() service.IStoreDesktopSetting {
|
||||
client, b := mqtt.GetClient("emqx")
|
||||
if !b {
|
||||
return nil
|
||||
}
|
||||
return &sStoreDesktopSetting{
|
||||
mqttCLient: client,
|
||||
}
|
||||
return &sStoreDesktopSetting{}
|
||||
}
|
||||
func init() {
|
||||
service.RegisterStoreDesktopSetting(New())
|
||||
@ -74,7 +67,11 @@ func (s *sStoreDesktopSetting) Save(ctx context.Context, in model.SaveDesktopSet
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = s.mqttCLient.Publish(fmt.Sprintf("/desktop/%d", in.StoreId), marshal)
|
||||
client, b := mqtt.GetClient("emqx")
|
||||
if !b {
|
||||
return nil, gerror.New("获取MQTT客户端失败")
|
||||
}
|
||||
err = client.Publish(fmt.Sprintf("/desktop/%d", in.StoreId), marshal)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user