In the last chapter, we built a simple web application that can serve HTML pages. Let's add some more functionality to our application. We have to build a chat app, so we will need some sort of real-time event framework. Luckily for us, there is Socket.IO, which will provide us with this real-time communication. Socket.IO fits right into the entire evented nature of Node.js. The whole paradigm of Socket.IO is completely different from using a web server. Socket.IO uses WebSockets to create a connection between the server and client. You will need to understand all this to get Socket.IO to do what you want it to. In this chapter, we will cover the following topics:
Sending and receiving events
Creating rooms to divide users
Adding and reading data from sessions
Authenticating connections
Integrating Socket.IO with what we have built already