mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-04-23 02:48:34 +08:00
[优化]
This commit is contained in:
@@ -61,7 +61,8 @@ taos:
|
||||
config: ""
|
||||
|
||||
mqtt:
|
||||
broker: http://127.0.0.1:18083/api
|
||||
broker: tcp://127.0.0.1:1883
|
||||
httpBroker: http://127.0.0.1:18083/api
|
||||
qos: 1
|
||||
username: dbda318b31319d49
|
||||
password: wwqPbYu9BCsIFgW3m0aICmRrvxUHcIi44AQuG24wQARE
|
||||
|
||||
@@ -20,9 +20,9 @@ const SubscribeTopicsInfo string = "subscribe"
|
||||
func GetEmqInfo(infoType string) ([]map[string]interface{}, error) {
|
||||
var url string
|
||||
if infoType == ClientsInfo {
|
||||
url = fmt.Sprintf("%s/v5/clients?_page=1&_limit=100000", global.Conf.Mqtt.Broker)
|
||||
url = fmt.Sprintf("%s/v5/clients?_page=1&_limit=100000", global.Conf.Mqtt.HttpBroker)
|
||||
} else if infoType == SubscribeTopicsInfo {
|
||||
url = fmt.Sprintf("%s/v5/subscriptions?_page=1&_limit=100000", global.Conf.Mqtt.Broker)
|
||||
url = fmt.Sprintf("%s/v5/subscriptions?_page=1&_limit=100000", global.Conf.Mqtt.HttpBroker)
|
||||
} else {
|
||||
return nil, errors.New("invalid infoType")
|
||||
}
|
||||
@@ -67,7 +67,7 @@ func Publish(topic, clientId string, payload interface{}) error {
|
||||
return errors.New("未获取到MQTT连接")
|
||||
}
|
||||
global.Log.Debugf("send data to clientId: %s, topic:%s, payload: %v", clientId, topic, payload)
|
||||
url := fmt.Sprintf("%s/v5/publish", global.Conf.Mqtt.Broker)
|
||||
url := fmt.Sprintf("%s/v5/publish", global.Conf.Mqtt.HttpBroker)
|
||||
pubData := map[string]interface{}{
|
||||
"topic": topic,
|
||||
"payload": payload,
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package config
|
||||
|
||||
type Mqtt struct {
|
||||
Broker string `mapstructure:"broker" json:"broker" yaml:"broker"`
|
||||
Qos int `mapstructure:"qos" json:"qos" yaml:"qos"`
|
||||
Username string `mapstructure:"username" json:"username" yaml:"username"`
|
||||
Password string `mapstructure:"password" json:"password" yaml:"password"`
|
||||
Broker string `mapstructure:"broker" json:"broker" yaml:"broker"`
|
||||
HttpBroker string `mapstructure:"httpBroker" json:"httpBroker" yaml:"httpBroker"`
|
||||
Qos int `mapstructure:"qos" json:"qos" yaml:"qos"`
|
||||
Username string `mapstructure:"username" json:"username" yaml:"username"`
|
||||
Password string `mapstructure:"password" json:"password" yaml:"password"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user