完善功能
This commit is contained in:
18
utility/mqtt/mqtt.go
Normal file
18
utility/mqtt/mqtt.go
Normal file
@ -0,0 +1,18 @@
|
||||
package mqtt
|
||||
|
||||
import "context"
|
||||
|
||||
type MQTTClient interface {
|
||||
Publish(ctx context.Context, topic string, payload interface{}) error
|
||||
Subscribe(topic string, handler func(payload interface{})) error
|
||||
}
|
||||
|
||||
var clients = make(map[string]MQTTClient)
|
||||
|
||||
func RegisterClient(name string, client MQTTClient) {
|
||||
clients[name] = client
|
||||
}
|
||||
|
||||
func GetMQTTClient(name string) MQTTClient {
|
||||
return clients[name]
|
||||
}
|
||||
Reference in New Issue
Block a user