-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathREADME
41 lines (28 loc) · 948 Bytes
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
This is a simple MQTT client on node.js
The lib is still under developing.
Author: FAN Yilun @ CEIT
API
Event: ‘sessionOpened’
Fired when a session with broker is opened sucesffully.
Event: ‘mqttData’
Fired when data is available for client, topic and payload have been extracted from data.
client.addListener(‘mqttData’, function(topic, payload){
});
Event: ‘openSessionFailed’
Fired when a session can not be established.
Event: ‘connectTimeOut’
Fired when cant establish a connection with server.
MQTTClient(port, host, clientID);
Construct a instance of mqtt client.
@port: port number, like 1883.
@host: server ip address.
@clientID: client name for server.
subscribe(sub_topic);
Subscribe to a topic.
@sub_topic: topic to be subscribed.
publish(pub_topic, msg);
Publish messages to a topic.
@pub_topic: publish topics.
@msg: payload data, can be anything, string, bytes.
disconnect();
Disconnect with server.