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_IotServiceStart] = fmt.Sprintf(Topic_IotServiceStart, sysCode, iotCode) topicMap[Topic_IotServiceStop] = fmt.Sprintf(Topic_IotServiceStop, 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 GetIotServiceStartTopic() string { return topicMap[Topic_IotServiceStart] } func GetIotServiceStopTopic() string { return topicMap[Topic_IotServiceStop] } func GetLogReqTopic() string { return topicMap[Topic_IotLog] } func GetQdTopic() string { return topicMap[Topic_IotQd] } func GetCjTopic() string { return topicMap[Topic_IotCj] }