GithubHelp home page GithubHelp logo

patchat's Introduction

PatChat

Simple Chatting Application, with a server written in C, and Client in C++ and C#

##Features

  1. Heartbeat from server to Clients connected every 5-ish seconds
  2. Broadcast a message to all connected clients
  3. Send a message to a specific client
  4. Create username
  5. Login as a user
  6. List all connected users
  7. Endless unique usernames of up to ten characters
  8. Up to 5 clients connected at once
  9. Server ping

##Client Commands NEW USERNAME

Usage: NEWUSER (name)

Creates a new username in the chat server

BROADCAST MESSAGE

Usage: BROADCAST (msg)

Sends a message to all connected users

LIST USERS

Usage: LIST

Lists all corrently connected users

PING

Usage: PING

Get a PONG from the server

SEND MESSAGE

Usage: SEND $(user) (msg)

Send a message to the user specified, this is echo'd to the sender

BEAT

HEart beat sent from server to clients

ACK

Client acknowledge heartbeat

##Challenges

  • Client recieve. The client must listen all the time for an incoming message from the server. To overcome this a thread is created which listens all the time, by using an Asynchronous NetworkStream.BeginRead() in a while loop.
  • Server HeartBeat. The server sends a heart beat to the connected clients every 5 seconds - this is handled in it's own thread.
  • Server Username storage. The server saves new usernames to a text file, and reads from this file on startup. This gives persistent usernames so a if the server is quit the usernames are remembered.

##To Improve

  • Dynamic commands, maybe from a setup file etc
  • Server
    • Connected client FD in a struct with their username too.
    • Thread ID's stored in a separate array - should be in the CURRENT_CONNECTIONS array or structs
    • The server doesn't act on the heartbeat ACK from the clients, either remove it or find a use for it
    • The server had no way of being quit once it's running, so although the code in place to free memory used and join the threads, it's never used
    • Refactor the source code into different files
    • Dynamic list of usernames which can grow/shink as clients connect
    • Saving usernames to a file for later re-use
    • Options Flags
  • Client
    • If running for ages the garbage collector throws an error as it's unable to allocated some memory - not sure yet where it's being allocated. Doesn't seem to be present in QT Gui
    • GUI would be nice, failing that a more smart console interface
    • LOGOUT command
    • Some client side checking of the replies from the Server or the input commands Server side does the checking so this is pointless extra processing

##Server Design Although the server doesn't use 'state's, the following diagram helps to explain what it does

##GUI Images

patchat's People

Contributors

geekskick avatar

Watchers

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