![]()
Table of Contents
Socket.IO Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why Subscribe?
Free Access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Sections
Getting ready
How to do itā¦
How it worksā¦
There's moreā¦
See also
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
1. Wiring It Up
Introduction
Creating a Node HTTP server with Socket.IO
Getting ready
How to do itā¦
How it worksā¦
There's moreā¦
Creating an Express server with Socket.IO
Getting ready
How to do itā¦
How it worksā¦
See also
Using Socket.IO as a cross-browser WebSocket
Getting ready
How to do itā¦
How it worksā¦
There's moreā¦
See also
Debugging on the client
Getting ready
How to do itā¦
How it worksā¦
There's moreā¦
See also
Debugging on the server
Getting ready
How to do itā¦
How it worksā¦
There's moreā¦
2. Creating Real-Time Dashboards
Introduction
Loading static data from the server
Getting ready
How to do itā¦
How it worksā¦
There's moreā¦
Creating a server-side clock
How to do itā¦
How it worksā¦
Loading data from MongoDB
Getting ready
How to do itā¦
How it worksā¦
Real-time analytics
How to do itā¦
How it worksā¦
There's moreā¦
Handling connection timeouts
Getting ready
How to do itā¦
How it worksā¦
3. Having Two-Way Conversations
Introduction
Creating a simple chat room
Getting ready
How to do itā¦
How it worksā¦
There's moreā¦
Managing the socket life cycle
How to do itā¦
How it worksā¦
Emitting a private message to another socket
Getting ready
How to do itā¦
How it worksā¦
Sending messages to all the sockets, except for the sender
How to do itā¦
How it worksā¦
Building a multiplayer tic-tac-toe game
Getting ready
How to do itā¦
How it worksā¦
4. Building a Room with a View
Introduction
Creating chat channels with namespaces
Getting ready
How to do itā¦
How it worksā¦
Joining rooms
Getting ready
How to do itā¦
How it worksā¦
Leaving rooms
Getting ready
How to do itā¦
How it worksā¦
Listing rooms the socket is in
Getting ready
How to do itā¦
How it worksā¦
There's moreā¦
Creating private rooms
Getting ready
How to do itā¦
How it worksā¦
Setting up a default room
Getting ready
How to do itā¦
How it worksā¦
5. Securing Your Data
Introduction
Implementing basic authentication
Getting ready
How to do itā¦
How it worksā¦
Performing token-based authentication
Getting ready
How to do itā¦
How it worksā¦
Handling server-side validation
Getting ready
How to do itā¦
How it worksā¦
Locking down the HTTP referrer
How to do itā¦
How it worksā¦
Using secure WebSockets
Getting ready
How to do itā¦
How it worksā¦
6. Performing a Load Balancing Act
Introduction
Performing load balancing with the Nginx server
Getting ready
How to do itā¦
How it worksā¦
Using the Node.js cluster
Getting ready
How to do itā¦
How it worksā¦
Using Redis to pass events between nodes
Getting ready
How to do itā¦
How it worksā¦
Using Memcached to manage multiple nodes
Getting ready
How to do itā¦
How it worksā¦
Using RabbitMQ to message events across nodes
Getting ready
How to do itā¦
How it worksā¦
7. Streaming Binary Data
Introduction
Broadcasting an image to other sockets
Getting readyā¦
How to do itā¦
How it worksā¦
There's moreā¦
Uploading an image to the filesystem
Getting readyā¦
How to do itā¦
How it worksā¦
Uploading an image to Amazon S3
Getting readyā¦
How to do itā¦
How it worksā¦
Streaming audio
How to do itā¦
How it worksā¦
Streaming live video
How to do itā¦
How it worksā¦
8. Integrating with Mobile Applications
Introduction
Throwing an alert when the socket connects
Getting ready
How to do itā¦
How it worksā¦
Pushing up data from the server
Getting ready
How to do itā¦
How it worksā¦
Responding to tap events from the device
How to do itā¦
How it worksā¦
Doing server-side pagination
Getting ready
How to do itā¦
How it worksā¦
Triggering hot deploys
How to do itā¦
How it worksā¦
Index
![]()
Copyright Ā© 2015 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: October 2015
Production reference: 1081015
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78588-086-5
www.packtpub.com
![]()
Author
Tyson Cadenhead
Reviewers
Gonzalo Ayuso
George Brassey
Commissioning Editor
Amarabha Banerjee
Acquisition Editor
Reshma Raman
Content Development Editor
Mayur Pawanikar
Technical Editor
Siddhesh Ghadi
Copy Editor
Relin Hedly
Project Coordinator
Kranti Berde
Proofreader
Safis Editing
Indexer
Mariammal Chettiyar
Graphics
Disha Haria
Production Coordinator
Conidon Miranda
Cover Work
Conidon Miranda
![]()
Tyson Cadenhead works as a senior JavaScript engineer at Aloompa in Nashville, Tennessee. He has dedicated his professional career to building large-scale applications in JavaScript and Node. Tyson addresses audiences at various conferences and programming meetups on how to build real-time web applications with Socket.IO or Meteor.js. He blogs on topics such as JavaScript and web technologies at http://www.tysoncadenhead.com.
Tyson lives in the greater Nashville area with his wife and two sons, where he enjoys gardening, raising chickens, reading philosophy and economics books, and playing guitar.
![]()
Gonzalo Ayuso is a web architect and specializes in open source technologies. He has more than 15 years of experience in web development. Gonzalo holds extensive experience in delivering scalable, secure, and high-performance web solutions to large-scale enterprise clients.
He has a varied background, especially in providing backend code. Gonzalo mainly focuses on Internet technologies, databases, mobile development, and programming languages, especially PHP, Python, and JavaScript. He blogs at http://gonzalo123.com. Gonzalo also likes to speak at technology conferences and organize coding dojos. You can also follow him on Twitter at @gonzalo123.
George Brassey is a developer from London. He loves art, music, and technology. George earned a degree in cinema studies from the New York University and...