O'Reilly logo

CoffeeScript Application Development Cookbook by Mike Hatfield

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

Communicating in real time with Socket.io

Socket.io is a node library that facilitates real-time two-way communication between the HTTP server and the web client. It has support for platforms, browsers, and devices.

In this section, we will see how to configure Socket.io with the express server and process messages between the client and server.

You can get more information on Socket.io from the project's home page at http://socket.io/.

Getting ready

We will be using an express server as our HTTP server configured to use the Jade view engine.

We begin by defining our application's node dependencies in a file named package.json:

{ "name": "socket-demo", "description": "Socket.io Demo", "dependencies": { "express": "~3.4", "jade": "~0", "socket.io": "~0.9" ...

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