I want to create a chat room using HTML5 web sockets, but am pretty lost. From what I can tell, the following is required:
- A browser that supports web sockets (Chrome, Safari)
- Some kind of server-side scripting
- Some kind of client-side scripting
I’ve got #1 down 🙂 but #2 is seriously tripping me up. Beyond amateur PHP work (generally within the context of Drupal), I have pretty much no experience coding on the server-side of things. I tend to code a lot in Javascript, and have read fantastic things about node.js. So I thought I’d try using it to play around with web sockets.
I’ve installed node.js to my Mac Leopard machine (it installs to Home > node), but I really have no idea where to go from there. The node.js website provides a “Hello World” example, which I’ve tried (I put the code into an example.js file, and saved that in the root of the “node” folder), but I only get the following response in Terminal:
Server running at http://127.0.0.1:8124/
I would LOVE a node.js and web sockets for dummies kind of thing. Thanks for any help that can be provided.
This may be slightly more advanced but it does provide a decent WebSocket layer for node.js: http://github.com/LearnBoost/Socket.IO-node
That said, if you haven’t done much server-side stuff, it might be better to get a feeling for the http protocol including how a request and response is constructed, how headers are added etc. (outside of node). Once you have a better sense for this, node.js will be much easier to understand.
This tutorial should give you a basic overview:
http://www.tutorialspoint.com/http/index.htm
This stuff becomes even more important when dealing with websockets