· Overview
The Everyware Device Cloud (EDC) platform provides support for Asynchronous REST/Comet APIs. This solution allows client applications to use HTTP and REST to subscribe on topics of interest and have matching data being streamed to them in real-time. Together with the ability of publishing data through the REST API described in the previous section, this completes the Everyware Device Cloud (EDC) offering of a full MQTT to HTTP bridge.
The following example illustrates how the EDC Comet API can be used to receive streaming data using REST APIs.
Complete the following steps before starting this example:
edc-java-client
example detailed in Connecting to the
Cloud in Java to publish data to your Everyware Cloud account in
real-time.
Download the edc-comet example available on the GitHub repository at https://github.com/eurotech/edc-examples/.
Under edc-comet/src/main/webapp
, o
pen
the file index.html
in your
favorite programming editor. This file follows the data model used in the edc-java-client
example and assumes that
your data is published under the sample/data
topic and contains metrics named int, dbl,
flt
.
Change the following lines of code to use your Everyware Cloud Username, Password, and Account and save your changes.
|
Using the Firefox or Safari browser, open index.html
. Click on the Subscribe
button shown in the following screen captue.
In Eclipse, run the edc-java-client
application by selecting the green Run button in the Launch toolbar
to make a connection to the Cloud and start publishing data. The data displays
in real-time as shown in the following screen capture.
See the full JavaScript code for details on the API operation.
This is a very simple example to show the Comet/streaming capabilities of the EDC platform. You are encouraged to package this example into a proper WEB application before deploying it into production.