node-chat is a good working example of the power of nodejs . However some people have trouble getting started with the source code of node-chat application. In order to help to you get started I have developed the skeleton of application in 12 different steps.
The step1 is as simple as this .
I developed this application with node version 0.1.32 . Installing node is easy.
git clone git://github.com/ry/node.git cd node git checkout v0.1.32 ./configure make make install
Checking out source code
All the 12 steps are tagged with step1 to step12. This is how you can get code for tag step1.
git clone git://github.com/neerajdotname/node-chat-in-steps.git cd node-chat-in-steps git checkout -b personal_step1 step1
If you want to go to step2 the just do
git checkout -b personal_step2 step2
Starting server and visiting page
After the server has been started visit http://localhost:8002 .
Functionalities in different steps
- create a server that responds with hello world on port 8002
- create an index.html and serve it
- introduce util.js
- change the logic so that any static file is served
- show 404 in case no file is found
- add jquery-1.4.2.js
- add client.js
- change index.html to prompt user for nickname
- send a join request when user enters nick name
- respond with a JSON in reply to /join request
- after ther nick name is accepted display chat screen
- create session object which identifies if a person is already in
- send this session object back to client when a person joins in
- if the nick is in use the provide that feedback to user
- add style.css
- after logging in display current time
- display number of active users logging in
- after showing the toolbar send a request /who
- capture the number of active users
- display message that user joined after a user joins chat
- better timestamp while displaying message
- when user hits enter then invoke send function