Pushing up data from the server
Using Socket.IO in a Cordova app is exactly the same as using it on a website. We emit events and listen for events. In the mobile device context, one interesting application is using Socket.IO as an interface over a third-party API. When the mobile device uses Socket.IO to kick off requests to the API, it doesn't have to wait for the request to complete. It will simply get a message when this occurs.
In this recipe, we will use Socket.IO as an interface to make a request to the openweathermap.org
API.
Getting ready
To make request to a third-party API, we will use the request library. It can be installed by running npm install request
in your command line.
How to do it…
To create a weather app that interfaces with a ...
Get Socket.IO Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.