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

Responding to tap events from the device

One cool thing about having a central server-side location to emit events from using Socket.IO is that you can use it as an API for multiple applications.

In this recipe, we will emit events to the server every time a user taps on a button on our app. The server will then emit the tap data to the client side, where it will be displayed on an analytics page.

This technique can be useful for gathering analytics data in real time, and watching the results of A/B testing as they happen.

How to do it…

To respond to tap events from the device by updating the counts on our analytics page, follow these steps:

  1. First, we will create our new Cordova app by running cordova create app com.client.tapsclientTaps.
  2. Next, we will ...

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