This is a hotel manager , implemented in CPP. Some of the available commands and their schemas
signup <username to be checked >
login <username> <password>
9
book_room <room_id> <bed_count> <start_date> <end_date>
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 ------> image1.png
Utility methods contain serialization and dumping , Printing the server response happens on each server receipt.
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
Call back functions
Server.h Gives basic communication utility with the client , deserializes and serializes the messages in between with it’s functions .
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
JSON utilities enabled with nlohmann library and hand written Date utility for working with dates
Hotel managment logic :
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 )
Run server :
Run client :
successful login :
Login failed :
Logout :
View user information :
View all users :
View Rooms Information :
Leaving room :
Successful signup :
Error 403 :
Error 503:
Successful Booking :
Add Room :
Modify Room :
Remove Room :
Edit information :
Canceling :
Error 451 :
Error 101 :
Error 108 :
Error 111 :
Error 102 :
Error 231 :
Error 109 :
Error 311 :
View Empty room information :
Error 102 (leaving room):