Week 2 – Live Web – ChatBox(WebSocket)

For this week, we learned how to use web socket and server to host our website.

Installing

First, go to Digital Ocean to register an account. On Digital Ocean, we will be able to get an IP address.

Secondly, open the terminal. In the command line, follow these steps:

ssh root@the IP address from digital ocean

installing node and nmp:

apt-get update apt-get install nodejs apt-get install nodejs-legacy apt-get install npm

after those steps, create the javascript and html file
server.js/index.html –>put them somewhere on your computer

Uploading

In order to upload to your server, we need to use a tool that will allow us to connect via SSH to transfer the files. I have found that Fetch and Cyberduck are good tools.To connect, choose “SFTP”, under “Hostname” or “Server” use the IP address emailed to you by Digital Ocean. The “username” is “root” and the “password” is what you just created in Terminal.

To Run it

ssh root@YOUR_IP
cd directory_you_just_created
npm install socket.io
node server.js

website: http://YOUR_IP:8080/index.html

I just modified the sample code a bit and made it also reply to the sender's side a bit:




Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s