Coder Social home page Coder Social logo

node-socket-chat's Introduction

Private-Chat-Application-using-MongoDB-and-Socket.io

This repository contains a fully functional private chat application using MongoDB, Socket.io and Express that supports real-time chatting and also allows to retrieve chat when logged in later.

Tech-stack -

  • HTML, CSS (for front-end interface)
  • JavaScript (both front-end behaviour and in the back-end)
  • Node.js and Express.js (for back-end server)
  • Socket.io (for real-time interaction between the client and the server)
  • MongoDB (as database to store chats, online users etc.)

Features of this app -

  • The app contains real-time chat between two private users
  • The chat history can be retirieved later when the chat is accessed by the user
  • The chat between two people will not be broadcasted to other users online
  • If an active user sends a message to another user while he is offline, the other user will be able to retirieve message later when he accesses the chat

Usage Guide -

  1. Install Node.js and MongoDB on your system. Check using the following commands in the terminal -
$ node -v
$ mongod --version
  1. Open your terminal and run the following -
$ git clone https://github.com/neelabhsinha/Private-Chat-Application-using-MongoDB-and-Socket.io/
$ cd Private-Chat-Application-using-MongoDB-and-Socket.io
$ npm install
$ node server.js
  1. Now, the server is running, open the link http://localhost:5000/chat.html to access the chat interface

  2. Type your name and the 2nd person name and press done to establish a connection. You will see the entire chat history retrieved between the two people.

  3. Open the same URL in another browser/tab and establish the other half of the connection

  4. Send messages from any end to see the functioning

  5. Close when you have to exit the chat

Feel free to try different cases, like when one user is offline, when both users are online but one of them is chatting with other person, etc.

Functionality -

  • When a user logs in, his'her record is maintained in online users collection, and the entire chat history is retrived from the database and displayed using socket.io
  • When he sends messages, it's checked if the recipient is online or not. If yes, message is sent to him. If not, nothing happens. In both the cases, message is stored in database for later access
  • When a user disconnects, he'she is removed from online users database

node-socket-chat's People

Contributors

hhoomph avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.