A chat server written in Javascript for Node.js
I'm always interested in writing applications in different languages. Personally, it helps me figure out which language is more interesting. Over the past couple of years, my time has been consumed by Java. Java is a great programming language, it's very powerful and there's a lot I've yet to learn from it. Although, a couple of days ago I was surfing the web very late at night and stumbled across this video. In the video, Ryan Dahl, the creator of Node.js, introduces Node.js and explains why its unique. The presentation had good humour so I kept watching, but when I saw that he could create a chat server with a few lines of code, I was astonished and immediately began reading more about the language.
The next day, I woke up and prepared to write my first Hello World application in JavaScript, which lucky enough for me, the syntax was similar to Java, therefore it was easy to understand. Hello World applications are never really that impressive, so I decided to challenge myself to write a chat server, one that not only looked neater, but provided the user more features. So here I am today, ready to show off my first Node.js application.
If you're lucky, you might be able to catch a live demo here.
When you first connect to the Chat server, you get a pop-up dialogue that lets you choose a nickname to be identified by. This is not saved, so if you change your username or leave the chat, someone else can use it.
[caption id="" align="alignnone" width="1161"] Image of the pop-up dialogue prompting the connecting user to choose a nickname.[/caption]
[caption id="" align="alignnone" width="601"] Error displayed when the user attempts to choose a name that is already being used.[/caption]
After choosing your nickname, you can start chatting with other people in the chat, just like most chat application.
[caption id="" align="alignnone" width="1147"] Image displaying user connection messages. And the everyday fan boys.[/caption]
As you might notice, each message's header has the message sender and the time. The time is soon going to display the time since the last message rather than the time it was sent. There is a lot that can be done to improve this chat application and I intend to do my best to improve them. I definitely see myself creating more Node.js applications in the future, it is so easy yet very powerful.
One thing that sort of annoyed me was that every project has to contain its modules/dependencies, therefore making a project much larger.
Chat application source: on GitHub.
PS: Please feel free to criticize my work. I appreciate all feedback.