open-index/open-npm huggingface dataset:
npm package: @netmanage/mqttclient
Description: Cordova plugin for mqtt client
Author: jerome2408133697-lang
Latest version: 1.0.1

## Example


app.module.js
```
import { MqttClientPlugin } from '@netmanage/mqttclient';
@NgModule({
  providers: [
    MqttClientPlugin,
    ...
  ]
})
```

target.ts
```
import { MqttClientPlugin } from '@netmanage/mqttclient';
export class Target {
    constructor(private mqtt: MqttClientPlugin) {}
    example() {
        const url = ;
        const clientId = 'mqttclient_' + '000000';
        const options = {
            setCleanSession: true,
            setKeepAliveInterval: 60,
            setConnectionTimeout: 10,
            setAutomaticReconnect: true,
            trustAllCerts: true
        }
      
        this.mqtt.connect(url, clientId, options, ()=>{console.log('success')}, ()=>{console.log('failed')});
        
        this.mqtt.subscribe(zhuti, 1,
            () => {
                console.log('MQTT Connected via WebSocket res:');
            },
            (err)=>{
                console.error('Subscribe error:', err);
            });
        
        this.mqtt.on('message', (topic, message) => {
            console.log(`Received message from ${topic}: ${message}`);
        });
        
        this.mqtt.publish(topic, message, 1,
            ()=>{
                console.log('Publish topic: ' + topic + ', message: ' + message);
            },
            (err) => {
                if (err) console.error('Publish error:', err);
            });
        
        this.mqtt.disconnect(
            ()=>{
                console.log('mqtt.disconnect success');
            },
            (err)=>{
                console.log('mqtt.disconnect error: ', err);
            }
        );
    }
    this.example();
}
```