Skip to content

psalire/Chat-Application

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chat

COMPILER USED: gcc version 8.2.1 20180905 (Red Hat 8.2.1-3) (GCC)

Files

See readme.txt

Overview

How to use:

  1. Run make to compile program.
  2. Run server [port number] [-v (optional verbose)] to run server.
  3. Run client [IP address] [port number] [username] [-v (optional verbose)] to run client.
  4. In client:
    • /list to get list of waiting users.
    • /connect [username] to connect to a waiting user.
    • /wait to wait for a user to connect.
    • Ctrl+C to end waiting or to end a chat with a user.
    • /quit to quit the client program.

How it works:

Messages are passed in the form of a struct called Message:

/* Chat message structure */
typedef struct message {
    char content[4096], /* Message content */
         username[128]; /* Who the message is from */
    uint8_t type; /* Uses MessageType */
    uint16_t seq; /* Used for MSG_MULTIPLE */
} Message;

Variable uint8_t type defines what the message is for, using the following:

enum MessageType {
    CLOSED = 0, /* Server closed connection */
    MSG, /* MSG for CHAT */
    MSG_MULTIPLE, /* MSGs length >4096 will be chunked (TODO) */
    ADD_USER, /* Request to add user to server list */
    RM_USER, /* Request to remove user from server list */
    USER_INFO, /* Request for connection info on a user */
    LIST, /* Request for list of waiting users */
    SUCCESS,
    FAIL
};

Program Flow:

Server:

Server Flowchart

Client:

Client Flowchart

Limitations

  • CHAT messages with length >4096 are cut.
  • User names with length >4096 are cut.

About

A TCP based chat program in C++

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published