Communication - Chat Project
- Remi Bettan

- 15 ביוני 2016
- זמן קריאה 3 דקות
In this project, we had to design and implement a chat within Computers in the same LAN, as it exists in many companies in the industry.
The design and the definition of the Protocol has been performed in teams of three programmers. Then, each programmer had to implement all the system by himself.
For this purpose, the scope of work was divided in two parts:
- TCP part:
All the management of the chat, in the server's and client's side has been done in TCP. First, the client had to enter the system, so the first Menu included the following features:
@ Register
@ Login
@ Logout.
Then, after his entering the system, the second Menu was displayed to the client:
@ Create a chat Room
@ Close a chat Room
@ Join a chat Room
@ Leave a chat Room
@ Get a list of all chat Rooms
@ Get a list of the owned chat Rooms
@ Get a list of the members of a chat Room.
For each action, a message was sent by the client to the server, and then the server sent an answer to the client.
This ping pong between the client and server had been defined in the design stage, within the Protocol. A dedicated header file had been written for this issue and this header file remained the same during all the projects, for the three programmers who had designed it (besides some enumerator added for errors, which have been added later on, during the project implementation).
The modules in the TCP part were:
# In the Server's Scope:
## TCP Server Communication model (working with FD_SET): Responsible for getting the messages from the client and sending those within the main function of this module: the Application(), which in this case was the Chat Server Application. Then the Application would send to this module the server's answer message. This message is sent from this TCP Server Communication model module to the client.
## Server's Management module: Responsible for all the Application: messages are sent from this module to the "Chat Parser", which sends back the type of the received message (e.g. Request to register, or to Open a Chat Room - see all features above), and the sent data which is needed for this request (e.g. Name of the Chat Room for joining a Chat Room, name and password for Login). The relevant data is saved in Databases (see below modules) and the answer message is built through the Chat Parser before it is sent back to the client through the TCP Server Communication model.
## Chat Clients Database Manager: Responsible for saving the details of the Clients, which were: name, password, vector of owned Rooms, vector of participating Rooms.
## Chat Rooms Database Manager: Responsible for saving the details of the Chat Rooms, which were: name, ownerName, UDP IP reserved for this Chat Room, vector of Room's members.
## Other modules which are not to be detailed here ( logger, backup, time...).
- UDP part:
All the Chat was done via UDP (obvious because multicast is not possible with TCP). When a Room is joined by a client, two windows open in his screen, a little one for writing and a bigger one for reading the messages of the Room (as in whatsapp app). Then, the client can see and participate to the chat of this room.
A message is sent by the Server in this room in order to inform all this room's members that this user has entered the room.
When these chat windows open, the client saves in a database data on its open windows: IP, Port, pid of each window's process (the window is opened by calling to the system function, which includes fork and execv functions.
Then, when a client wants to exit a Room, and after the request is send to the Server and approved by him through the TCP protocol, the Client's Application closes the windows of this Room via pipes .
The project was successfully implemented and its accurate detailed design lead to a quite easy implementation.
See the Executive Diagram and the Class Diagram of the Design below:



תגובות