Giter Site home page Giter Site logo

p2p-chat-application's Introduction

P2P CHAT APPLICATION

Summary

In this project we are operating peer to peer chatting using high level socket programming. Briefly, P2P chat is a chat method which provides send messages directly communicating with peers without using servers.

We have two main component which are Server (registry) and Client (peer).

Simply, on client side, user will send register request to register himself into Server, after registering also user will send login request to login Server. After login processes user will be able to chat with other peers.

On server side, server has ability to accept and reject requests which comes from the users. If user logins in successfully, server will send online user list to user. And user will see online users to start chat.

Also server and client has different functionalities like checking and sending “hello” messages, etc.

Solution to Approach

We need to do more than one job at the same time. Therefore we are implementing multi- thread system.

On server side , we are using MongoDB to manage and store data. There are TCP socket which listens port 3131 and UDP socket which listens 5151. We are starting a thread for each user who wants to communicate with server to listen TCP socket and handle requests. These threads are working until user are logged out or ends to application. And we are starting one more thread to listen UDP socket and catch “hello” messages which comes from peers.

On client side , after login process, user starts a channel between himself and server. By using this channel, he makes server operations like sending request and sending “hello”

Also client has two main thread. First one is listening the chat requests which comes from other peers. Second thread is for get messages from peers and print these messages to chat screen.

Client has a data structure ( chat_list ). If other peers accept our chat request, the peer who sent the request add the user he want to communicate with into chat_list. If user wants to send a message, message will be sent everyone in the chat_list.

PROTOCOLS

We have 5 type request between server and client:

  • Register : In data part, we are sending “password”.
  • Login: In data part, we are sending “password”.
  • Search: In data part, we are sending the username which we want to search. We never use the request. Instead of we used “all online”.
  • Logout: In data part, we are sending ‘LOGOUT’ message.
  • All Online: In data part, we are sending ‘All’ message.

screen shot 2017-12-19 at 00 38 39

We have 2 different package type between client and client:

  • Message package:

    Type will be 0
    Type (b)
    Username (10s)
    Message (100s)
  • Notify and Request:
    In Notify, type will be “1”, Message will be “New User” and Data will be IP address. Also we are sending current chat_list to handle group chat. If new user appears, old users will be informed.
    In Request, type will be “0”, Message will be “CHAT REQUEST” and Data will be username.

    Type will be 1
    Type (b)
    Data (15s)
    Message (10s)
     chat_list

screen shot 2017-12-19 at 00 48 02

p2p-chat-application's People

Contributors

altuntasfatih 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.