Skip to content

Commit

Permalink
Add syntax highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
ctjhoa committed Apr 10, 2020
1 parent 35ed128 commit d5ad3fa
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ Usage
------------------------------------------------------------------------------

You have to import this service in your route or controller or component or service js class:
```
```js
import { inject as service } from '@ember/service';
...
@service mqtt;
```
### connect(host, [username], [password]): *RSVP.Promise*
Connect to the mqtt host and register a listener to the `mqtt-message` event:
```
```js
this.mqtt.connect('wss:https://test.mosquitto.org:8081').then( () => {
// Do stuff on connection established
});
Expand All @@ -40,7 +40,7 @@ this.mqtt.on('mqtt-message', (sTopic, sMessage) => {
});
```
### subscribe(topic): *RSVP.Promise*
```
```js
this.mqtt.subscribe('presence').then( (oGranted)=>{
// Do stuff after succesfully subscription to mqttTopic
});
Expand All @@ -50,22 +50,22 @@ this.mqtt.subscribe('presence').then( (oGranted)=>{
* *qos*: is the granted QoS level on it

### publish(topic, message): *RSVP.Promise*
```
```js
this.mqtt.publish('presence', 'Hello').then( () => {
// Do stuff after successfully published message
});
```

### unsubscribe(topic): *RSVP.Promise*
```
```js
this.mqtt.unsubscribe('presence').then( (oGranted)=>{
// Do stuff after succesfully unsubscription to mqttTopic
});
```

### mqtt-message [topic, message]: *Event*
New mqtt message received.
```
```js
this.mqtt.on('mqtt-message', (sTopic, sMessage) => {
// Do stuff with topic and message parameters
});
Expand Down

0 comments on commit d5ad3fa

Please sign in to comment.