made sc-mqtt module's client object fluent
This commit is contained in:
parent
a098963f90
commit
f71d1a4e78
1 changed files with 7 additions and 0 deletions
|
@ -97,6 +97,7 @@ function Client(brokerUrl, clientId){
|
||||||
}else{
|
}else{
|
||||||
client.connect(options);
|
client.connect(options);
|
||||||
}
|
}
|
||||||
|
return client;
|
||||||
},
|
},
|
||||||
publish: function(topic, message, qos, retained){
|
publish: function(topic, message, qos, retained){
|
||||||
if (typeof message == 'string'){
|
if (typeof message == 'string'){
|
||||||
|
@ -109,21 +110,27 @@ function Client(brokerUrl, clientId){
|
||||||
retained = false;
|
retained = false;
|
||||||
}
|
}
|
||||||
client.publish(topic, message,qos, retained);
|
client.publish(topic, message,qos, retained);
|
||||||
|
return client;
|
||||||
},
|
},
|
||||||
subscribe: function(topic){
|
subscribe: function(topic){
|
||||||
client.subscribe(topic);
|
client.subscribe(topic);
|
||||||
|
return client;
|
||||||
},
|
},
|
||||||
unsubscribe: function(topic){
|
unsubscribe: function(topic){
|
||||||
client.unsubscribe(topic);
|
client.unsubscribe(topic);
|
||||||
|
return client;
|
||||||
},
|
},
|
||||||
onMessageArrived: function(fn){
|
onMessageArrived: function(fn){
|
||||||
callback.setMesgArrived(fn);
|
callback.setMesgArrived(fn);
|
||||||
|
return client;
|
||||||
},
|
},
|
||||||
onDeliveryComplete: function(fn){
|
onDeliveryComplete: function(fn){
|
||||||
callback.setDeliveryComplete(fn);
|
callback.setDeliveryComplete(fn);
|
||||||
|
return client;
|
||||||
},
|
},
|
||||||
onConnectionLost: function(fn){
|
onConnectionLost: function(fn){
|
||||||
callback.setConnLost(fn);
|
callback.setConnLost(fn);
|
||||||
|
return client;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Reference in a new issue