Let's Chat
A real-time chat application where users can create their own room names.
About this project

The Let's Chat web application is a real-time web app where users can join or create their own rooms and start chatting with anyone in the room.

Websocket is an interesting computer communications protocol, providing full-duplex communication channels over a TCP connection and I wanted to get my feet wet in learning this technology.

I read about Websocket and Socket.io kept surfacing my search results and decided to take the plunge with Socket.io due to its ease of use platform and fall-back solutions in case certain devices/browsers are not compatible.

Architecture

There are two main parts to this client-server application.

The client-side presents two parts. First, a user can enter a user name and a room to join or create. Next, there is a call to the server-side and once a user joins a room, there is a main message area where users can view and send new messages in real-time. There is also a section where it lists the users currently in the room. All of interactive data such as the user name, room name, messages, etc. are appended by Mustache's templating and sent from the server-side.

The server-side takes advantage of the Node.js and Express with Socket.io sitting on top of them. Having developed REST APIs in the past, this was a bit strange to set up, but it works just fine.

It was certainly felt more like consuming an API rather can creating your own but that is one of the main reasons I choose Socket.io over vanilla Websocket.

The implementation of Socket.io was pretty straight forward. There are calling functions on on the server-side to join a room, send messages, etc. These functions are mostly initiated from the client-side.

The challange I had was that I wanted the URL of this web application to be at danhac.com but my hosting provider for this domain does not support Node.js. I decided to host the server-side on Heroku and establish a socket connection on the client-side to point to the server-side code on Heroku.

Mission Accomplished.

Technologies
  • Socket.io
  • Node.js
  • JavaScript
  • Mustache
  • HTML5
  • CSS3