Book Image

Building Scalable Apps with Redis and Node.js

By : Joshua Johanan
Book Image

Building Scalable Apps with Redis and Node.js

By: Joshua Johanan

Overview of this book

Table of Contents (17 chapters)
Building Scalable Apps with Redis and Node.js
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Finishing Socket.IO


We have built many little Socket.IO demonstration applications, and now is the time to create the Socket.IO we are going to use. We only need to update the authorization and connection functions. Let's get started. Open up index.js present in the socket.io folder and make the following changes to the require statements at the top:

var io = require('socket.io'),
  cookie = require('cookie'),
  cookieParser = require('cookie-parser'),
  expressSession = require('express-session'),
  ConnectRedis = require('connect-redis')(expressSession),
  redisAdapter = require('socket.io-redis'),
  redis = require('redis'),
  config = require('../config'),
  redisSession = new ConnectRedis({host: config.redisHost, port: config.redisPort}),
  redisChat = require('../redis/chat'),
  models = require('../redis/models'),
  log = require('../middleware/log');

Here, we are just pulling in the Redis functions we created and the model creation functions.

The next addition is adding a few lines...