So basically there are are few step need to beware of compare to our last time tutorial.
here is the link that send to me by my lecturer : http://tech.yeesiang.com/websocket-server-mobile-client/. if you are interested to this code can try to subscribe the blog.(yee siang i help you promote your blog. LOL )
You require to download Xampp, Node.js
To create the server you need to follow this few steps.
First, you need to have nodejs installed.
Save the code below into websock-server\index.js
Then, in your terminal/cmd, type npm install email@example.com to install the nodejs websocket library.
Make sure your port 8080 is not occupied by other program as I am using port 8080 in this example.
Next, in your terminal/cmd, cd into the folder and type node index.js
Save then you will see this in your folder
This is able to use as server. Is user a output screen . Every time when people log in or out will have update. Then everything when people key in message it automatically update on the page.
After create the server we need to create the client files.
For the client part, the tutorial ask to going to create 2 interface, one for sending and receiving chat msg (index.htm), another for receiving chat msg only (logger.htm) which is the display.
You will need to change the Server IP in it into yours (ws://192.168.0.200:8080)
So now i can open the index.htm and type a msg, and it will appear on the space below the input box, as well as in logger.htm
I can even put index.htm into phonegap (need to provide option for user to enter the Server IP) and it can serve as a ‘controll’ while logger.htm can be modified to be a ‘receiver’ which also know as a "output".
Put the two files in the websock-client folder
index.htm source code
Then logger.htm source code
To try it copy the websock-client files into xampp htdocs first so that phone are able to connect to the folder to internet database.
Start xampp first before launch in browser. and also terminal as well .
So this will be how it will look like