This module provides an rpc interface for an mqtt connection, in essence this is a request and response strategy which uses an MQTT topic structure as transport.
Installation
npm install mqtt-rpc
server
Exposes an array of functions which retrieves and returns data.
var mqtt = mqttrpc = debug = 'remote-time:server'; var settings = reconnectPeriod: 5000 // chill on the reconnects // client connectionvar mqttclient = mqtt; // build a mqtt new RPC servervar server = mqttrpc; // optionally configure the codec, which defaults to JSON, also supports msgpackserver; // provide a new methodserver;
client
Consumes the api exposed by the previous example.
var mqtt = mqttrpc = debug = 'remote-time:client'; var settings = reconnectPeriod: 5000 // chill on the reconnects // client connectionvar mqttclient = mqtt; // build a new RPC clientvar client = mqttrpc; // optionally configure the codec, which defaults to JSON, also supports msgpackclient; // call the remote methodclient;
License
Copyright (c) 2013 Mark Wolfe Licensed under the MIT license.