Integrate a Library
Next, let us select and integrate an MQTT library into your web app.
In order to run the MQTT.js with Browserify on the browser, convert the MQTT.js, which runs on Node.js, to a JS file which runs on the browser.
Run the following commands on a PC where Node.js and npm are installed:
$ npm install -g browserify $ npm install mqtt $ cd node_modules/mqtt $ npm install . $ browserify mqtt.js -s mqtt > browser-mqtt.js
Incorporate the Paho JS file into your web app. Mqttws31.js was available when this tutorial was developed. Replace the file name with the one that you downloaded in the following sample codes.
The index.html should look like this after incorporating a library:
The web app directory should have three of these files:
KiiSDK.js: This is the JS file of the Kii Cloud SDK.
main.js: You created this file in the previous topic.
browser-mqtt.js: You created this file if you use MQTT.js.
mqttws31.js: You downloaded this file if you use Paho.
Let us move to the next step: Implement Receive Processing
|<< Create a Web App||Implement Receive Processing >>|