SyntheticDemon / Hotel-Manager

‫‪CN_CHomeworks_1‬‬‫‌‬
1 stars 0 forks source link

Hotel Manager

This is a hotel manager , implemented in CPP. Some of the available commands and their schemas

Signup

signup <username to be checked >

Login

login <username> <password>

Logout

9

Book Room

book_room <room_id> <bed_count> <start_date> <end_date>

Cancel Room

cancel <room_id> <bed_count>

Build with

make

Clean with

make clean

Run Client with

./Client.exe

Run server with

./Server.exe

810199395 Pouriya Tajmehrabi

810199392 Mohammad Amin Pourzare

Simple Client Server architecture

JSON encoded and serialized data transfer

Request Type determines corresponding server response method instead of url regex matchijng

A Wrapper around UNIX sockets manages the connection with the server and vice versa .

The connector class in the client alt text ------> image1.png

Utility methods contain serialization and dumping , Printing the server response happens on each server receipt.

alt text

How the server handles multiple clients, The server handles multiple clients using cpp threads, when the server accepts a client, it creates and stores the designated FDS and uses them for later , Handle-client function is used for this affair

alt text

Call back functions

alt text

Server.h Gives basic communication utility with the client , deserializes and serializes the messages in between with it’s functions .

alt text

Mutex locks are used for maintaining thread safety with the json files that are altered , JSON storage is updated after each insertion, functions that need to be thread safe because of race conditions handle races by acquring mutex locks

alt text

JSON utilities enabled with nlohmann library and hand written Date utility for working with dates

alt text alt text alt text alt text

Hotel managment logic :

alt text

1- Overlap occupations finds out the capacity of each room for a potential reservation

2- Authenticate checks the credential user password for entry

3- Invalid date utility is an interface that recognizes faults

4- update_reserves_with_time() , updates the reserves on each call back execution

5- Is User admin checks if the user is admin

A sample of a call back function that creates response ( each executing thread for the client calls this function )

alt text

alt text

alt text

Outputs :

Run server :

alt text

Run client :

alt text

successful login :

alt text

Login failed :

alt text

Logout :

alt text

View‬‬ ‫‪user‬‬ ‫‪information :

alt text

‫‪‬‬ View‬‬ ‫‪all‬‬ ‫‪users :

alt text

View‬‬ ‫‪Rooms‬‬ ‫‪Information :

alt text

Leaving‬‬ ‫‪room :

alt text

Successful signup :

alt text

Error 403 : alt text

Error 503: alt text

Successful ‫‪Booking‬‬ :

alt text

Add Room :

alt text

Modify Room :

alt text

Remove Room :

alt text

Edit‬‬ ‫‪information :

alt text

Canceling :

alt text

Error 451 :

alt text

Error 101 :

alt text

Error 108 :

alt text

Error 111 :

alt text

Error 102 :

alt text

Error 231 :

alt text

Error 109 :

alt text

Error 311 :

alt text

View Empty room information : alt text

Error 102 (leaving room):

alt text