jl-iot/mqtt/topic.go
walker 5f94a5a146 mqtt客户端添加请求处理公共实现
基于请求处理实现Iot日志查询请求处理器注册接口
2023-12-19 16:15:21 +08:00

44 lines
1.5 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package mqtt
import "fmt"
const (
// IOT服务状态主题,第一个参数为应用编号,第二个参数为客户端编号
Topic_IotServiceState string = "/%s/%s/iotss"
// IOT服务启动(请求响应)主题,第一个参数为应用编号,第二个参数为客户端编号
Topic_IotServiceStart string = "/%s/%s/iotstart"
// IOT服务停止(请求响应)主题,第一个参数为应用编号,第二个参数为客户端编号
Topic_IotServiceStop string = "/%s/%s/iotstop"
// IOT日志服务(请求响应)主题,第一个参数为应用编号,第二个参数为客户端编号
Topic_IotLog string = "/%s/%s/iotlog"
// IOT驱动数据主题第一个参数为应用编号第二个参数为客户端编号
Topic_IotQd string = "/%s/%s/iotqd"
// IOT采集数据主题第一个参数为应用编号第二个参数为客户端编号
Topic_IotCj string = "/%s/%s/iotcj"
)
var topicMap = make(map[string]string, 4)
func BuildTopics(sysCode, iotCode string) {
topicMap[Topic_IotServiceState] = fmt.Sprintf(Topic_IotServiceState, sysCode, iotCode)
topicMap[Topic_IotLog] = fmt.Sprintf(Topic_IotLog, sysCode, iotCode)
topicMap[Topic_IotQd] = fmt.Sprintf(Topic_IotQd, sysCode, iotCode)
topicMap[Topic_IotCj] = fmt.Sprintf(Topic_IotCj, sysCode, iotCode)
}
func GetIotServiceStateTopic() string {
return topicMap[Topic_IotServiceState]
}
func GetLogReqTopic() string {
return topicMap[Topic_IotLog]
}
func GetQdTopic() string {
return topicMap[Topic_IotQd]
}
func GetCjTopic() string {
return topicMap[Topic_IotCj]
}