0%

Book Description

Build modern real-time web applications powered by socket.io

  • Understand the usage of various socket.io features like rooms, namespaces, and sessions
  • Secure the socket.io communication
  • Deploy and scale your socket.io and Node.js applications in production
  • A practical guide that quickly gets you up and running with socket.io

In Detail

The expectations of users for interactivity withweb applications have changed over the past few years. No more does the user want to press the refresh button to check if new messages have arrived in their inbox; people expect to see updates in their applications in real-time. Mass multiplayer online games have given up the requirement of plugins and are built entirely in JavaScript. Socket.io enables you to build these highly interactive applications that work cross-browser.

"Socket.io Real-time Web Application Development" is a guide to building, deploying, and scaling highly interactive real-time web applications using socket.io. This book will guide you through the building of a chat system using Node.js and socket.io, helping you get familiar with various features of the framework. Going further it will empower you to deploy and scale your applications in production.

Introducing web application development with Node.js, this book walks you through developing of a full-fledged chat system built with socket.io and introducing all the concepts of socket.io and its usage in the process.

It introduces you to the different approaches of bidirectional communication between the browser and the web server and will show you how socket.io abstracts all this for you to provide a single unified and uniform API for messaging and eventing to develop cross-browser applications. It explains how to authenticate your users, segregate the communication to channels, build chat rooms, and handle and scale sessions. It explains the mechanics behind socket.io and it also introduces you to what is involved in deploying the application to production and the intricacies involved in scaling it.

This book will introduce you to all that is needed in browser-server communication to develop the next generation of interactive applications and games.

Table of Contents

  1. Socket.IO Real-time Web Application Development
    1. Table of Contents
    2. Socket.IO Real-time Web Application Development
    3. Credits
    4. About the Author
    5. Acknowledgement
    6. About the Reviewers
    7. www.PacktPub.com
      1. Support files, eBooks, discount offers and more
        1. Why Subscribe?
        2. Free Access for Packt account holders
    8. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Errata
        3. Piracy
        4. Questions
    9. 1. Going Real Time on the Web
      1. What is real-time web?
      2. A bit of history
      3. Applications of real-time web
        1. Gaming
        2. Social stream updates
        3. Business applications
        4. Web-based monitors
      4. Summary
    10. 2. Getting Started with Node.js
      1. The origin of Node.js
      2. Why Node.js
        1. JavaScript everywhere
        2. Event-driven design
        3. Corporate backing
      3. How to get Node.js
      4. Node.js package manager (npm)
      5. Hello World with Node.js
      6. Hello Web
      7. Routing the requests
      8. HTTP Methods
      9. Creating our own Modules
      10. Serving files
      11. Third party modules and Express JS
      12. Summary
    11. 3. Let's Chat
      1. Creating the application
      2. Designing the chat room
      3. Bringing in jQuery
      4. Socket.IO
      5. Handling events
      6. The server
      7. The client
      8. Summary
    12. 4. Making It More Fun!
      1. Giving names to users
      2. More on events
      3. Working with namespaces
      4. Rooms
      5. Listing the rooms
      6. Sharing the session
      7. Summary
    13. 5. The Socket.IO Protocol
      1. Why do we need another protocol?
        1. The WebSocket API
        2. The Socket.IO API
      2. The Socket.IO socket
      3. The Socket.IO connection
      4. Socket.IO messages
        1. Disconnect (0)
        2. Connect (1)
        3. Heartbeat (2)
        4. Message (3)
        5. JSON message (4)
        6. Event (5)
        7. ACK (6)
        8. Error (7)
        9. NOOP (8)
      5. Summary
    14. 6. Deploying and Scaling
      1. The production environment
      2. Running the application
      3. Keeping it running
      4. Scaling
      5. The node cluster
      6. Scaling up the application
      7. Tips for node in production
      8. Summary
    15. A. Socket.IO Quick Reference
      1. The server
        1. Instantiating socket
        2. Starting Socket.IO
        3. Listening to events
        4. Emitting an event
        5. Sending a message
        6. Sending a JSON message
        7. Broadcasting a message/event
        8. Sending a volatile message
        9. Storing socket data
        10. Getting the socket data
        11. Restricting to a namespace
        12. Joining a room
        13. Broadcasting messages/events in a room
        14. Leaving a room
        15. Changing the configuration
      2. Server events
        1. connection
        2. message
        3. disconnect
      3. The client
        1. Connecting to a socket
        2. Listening to events
        3. Emitting an event
        4. Sending a message
      4. Client events
        1. connect
        2. connecting
        3. disconnect
        4. connect_failed
        5. error
        6. message
        7. reconnect
        8. reconnecting
        9. reconnect_failed
    16. B. Socket.IO Backends
      1. Erlang
      2. Google Go
      3. Java
      4. Perl
      5. Python
      6. Summary
    17. Index