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-clientexample detailed in Connecting to the Cloud in Java to publish data to your Everyware Cloud account in real-time.
You should have already downloaded the edc-comet example available on the GitHub repository at https://github.com/eurotech/edc-examples/.
In your workspace under edc-comet/
index.html in your
favorite text editor. This file follows the data model used in the
edc-java-client example and assumes that
your data is published under the
topic and contains metrics named
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. (Note: this does not work
with Internet Explorer.) Click on the Subscribe button shown in the following screen
In Eclipse, run the
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.
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.