Friday, August 8, 2014

Creating Socket IO Node js and Json.

I had received a tutorial to create a chat room through websocket . And the tutorial are base on socket io. If you have interest to create one please visit :

By following the tutorial i am request to downlaod node.js as well.
Node.js basically is a platform built on Chrome's JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices. To download here is the link .

So base on the tutorial i first create a json file. In the json in the preset why are the data the you will like send and received.

After that i was request to install the library source of node.js into same folder below are the step to do that . i am using mac so below are the code for mac terminal

my chatroom folder is located at desktop a folder name socketio-chat. We need to install the library into the specific folder.
"cd" for commanf to open the folder
if want to check the can us "ls" for list
when you reach the folder then key in npm install--save to install.

Then check your folder whether you have a new folder name node_modules . if yes that means you had successfully download success.

Then i time for us to create the function. create a index.js file to key in the function. for now texting i am using the code that are provide by The coding basically setting a local server to let few browser to communicate with each other and function to check when there are user login or logout.

After setting up the server is time to create the interfaces. Use Css to style the form and link all the important files to the html files.

After everything have been done you text to run node index.js in terminal. if you get the reason of listening to 3000 like the image below that mean you had successfully create a local host port to let people send data to get live feedback from the website.

Then launch localhost:3000 in your browser to check whether the interface will pop out and is it the chatroom working .

at the terminal also will show update when they are people login.

If you dont want to follow through the website you are able to follow through the video tutorial below .


References, (2014). node.js. [online] Available at: [Accessed 8 Aug. 2014]., (2014). Socket.IO — Get started. [online] Available at: [Accessed 8 Aug. 2014].

References, (2014). node.js. [online] Available at: [Accessed 21 Aug. 2014]., (2014). Socket.IO — Get started. [online] Available at: [Accessed 21 Aug. 2014].
YouTube, (2014). Node.js & Chat Part One: The Basics. [online] Available at: [Accessed 21 Aug. 2014].

No comments:

Post a Comment