• Developed a Web-chat Box using socket.io, in which one person can send message to everyone (who are connected to the server) in one go or individually and also receive messages from them.
• Tech stack used: HTML, CSS, JavaScript, socket.io, express js
• IDE used: Visual Studio Code
->Why i choose socket.io for this ??
Writing a chat application with popular web applications stacks like LAMP (PHP) has normally been very hard. It involves polling the server for changes, keeping track of timestamps, and it’s a lot slower than it should be.
Sockets have traditionally been the solution around which most real-time chat systems are architected, providing a bi-directional communication channel between a client and a server.
It has a very simple layout. Users can exchange messages between them.
Note : This application works only on my system. I have to write localhost:1234 on browser's URL (where I hosted my server of this webchat application). So to start my server, I have to execute server.js file, then server becomes active and open this URL in two tabs of browser (just to look like two persons are chatting from two different system).
- First of all user has to login to the web chat app using username and password.
- After that chat box will open where user can send message to everyone(who are connected to the server) without specifying name.
- If user wants to send message to a particular person, then he/she needs to mention his/her name in textbox, then he/she could write message in message box and send message to him/her. They(online users) can also see the messages which they are exchanging between them.
- First of all create a folder and put all tha files as it is in that folder.
- Open cmd and type this following commands and after every command press enter
• npm init (This will create package.json)
• npm install express@4 (This will create node_modules folder and package-lock.json and install express js)
• npm i install socket.io (This will install socket.io)