CHAPTER 15

Real-Time Web with Socket.io

The major shift to client-side technology—loosely referred to as AJAX or Web 2.0—required big changes in the way web developers went about their work. As well as confronting greater performance issues and facing the problem of intermittent network connectivity, developers also must go through a change in mind set in order to appropriately architect an application with extensive client-side functionality.

If there is a “next big thing,” real-time functionality is it. However, along with the issues that client-server communications already bring come the special challenges of real time. Rather than using the traditional request-response model, developers need to think more abstractly about what the client is doing and take a more general approach to the design of web services.

Defining real-time applications

Before starting to look at code, it’s important to understand what real-time actually means. You can find a number of different definitions, some of which describe things that are easier to achieve than others.

However, in traditional computer science, real-time has a specific meaning that refers to the ability of a piece of software to complete work in a given time frame. For example, if a computer controls a washing machine, the computer must be able to calculate the level of water in a timely way so that the drum (tub) doesn’t overflow. Control computers are the obvious applications for these techniques—for example, car engine control ...

Get Smashing CoffeeScript 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.