Creating the streaming server
In this section, we will use Node to create the streaming server. The server will handle the client connections and the connection to the Twitter-streaming API; it will also manage the list of topics for all the clients who deliver tweets as they arrive.
We will begin by creating Twitter authentication tokens; we will learn how to use the Twit module to manage the connection to the Twitter API, and how to use Socket.IO to handle real-time communication between the server and the client application.
To follow the examples in this section, open the chirp-server
project directory in the terminal and run the following command to install the project dependencies:
$ npm install
This will create the node_modules
directory and download the project dependencies. If you haven't installed Node, download the binaries for your platform from http://nodejs.org/download/ and follow the instructions on the page.
Using the Twitter-streaming API
Twitter provides a streaming API...