O'Reilly logo

Socket.IO Cookbook by Tyson Cadenhead

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required