package mqtt_binding import ( "git.sxidc.com/go-tools/api_binding/mqtt_binding/mqtt_client" ) var ( topicPrefix string ) var mqttClientInstance *mqtt_client.MqttClient func Init(prefix string, opts *mqtt_client.MqttClientOptions) error { topicPrefix = prefix mqttClient, err := mqtt_client.NewMqttClient(opts) if err != nil { return err } err = mqttClient.Connect() if err != nil { return err } mqttClientInstance = mqttClient return nil } func Destroy() { if mqttClientInstance != nil { mqttClientInstance.Disconnect() mqtt_client.DestroyMqttClient(mqttClientInstance) mqttClientInstance = nil } }