{"id":23535160,"url":"https://github.com/tiuphun/rubik","last_synced_at":"2025-11-01T00:30:29.157Z","repository":{"id":262922712,"uuid":"888222294","full_name":"tiuphun/rubik","owner":"tiuphun","description":"Project lập trình mạng vui vẻ không quạu. Chương trình đồng đội combat lên sóng vào lúc 20h-22h hàng tối trên Teams, mời các bạn đón xem","archived":false,"fork":false,"pushed_at":"2025-01-18T15:29:33.000Z","size":3466,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-18T16:35:13.261Z","etag":null,"topics":["socket-programming"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tiuphun.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-14T02:47:03.000Z","updated_at":"2025-01-03T01:06:43.000Z","dependencies_parsed_at":null,"dependency_job_id":"7f046d65-9a89-4464-a52b-3c29e6af2d58","html_url":"https://github.com/tiuphun/rubik","commit_stats":null,"previous_names":["tiuphun/rubik-server","tiuphun/rubik"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tiuphun%2Frubik","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tiuphun%2Frubik/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tiuphun%2Frubik/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tiuphun%2Frubik/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tiuphun","download_url":"https://codeload.github.com/tiuphun/rubik/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239242107,"owners_count":19605954,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["socket-programming"],"created_at":"2024-12-26T01:15:20.734Z","updated_at":"2025-11-01T00:30:29.131Z","avatar_url":"https://github.com/tiuphun.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [IT4062E] Network Programming | Final Project: Online Rubik's Cube Game\n\n## Group 1 - Members\n| Student Name | Student ID |\n|--------------|------------|\n| Nguyen Tieu Phuong     | 20210692     |\n| Than Hai Phong   | 20210678     |\n| Kieu Thai Thinh | 20215246     |\n\n## Table of Contents\n\n- [Folder Structure](#folder-structure)\n- [Libraries Used](#libraries-used)\n- [Running the Project](#running-the-project)\n- [Server Setup and Processing](#server-setup-and-processing)\n- [Message Handling](#message-handling)\n- [Entity Models and Their Functions](#entity-models-and-their-functions)\n- [Queries](#queries)\n- [Database](#database)\n- [Constants](#constants)\n\n## Folder Structure\n\n## Libraries Used\n\nThe project uses the following libraries located under the [`include`](include) folder:\n\n- **nlohmann/json**: A JSON library for C++.\n- **openssl**: A robust, full-featured open-source toolkit for the Transport Layer Security (TLS) and Secure Sockets Layer (SSL) protocols.\n\n## Running the Project\n\nTo run the project, use the following commands:\n\n```sh\nmake\n./rubik-server\n```\n\nTo clean the build directory, use:\n\n```sh\nmake clean\n./rubik-server\n```\n\n## Server Setup and Processing\n\nThe server setup and processing are handled in `server.cpp` and `main.cpp`. The server listens for client connections, reads messages, processes them using `MessageHandler`, and sends responses back to the clients.\n\n\n```mermaid\nsequenceDiagram\n    participant MessageHandler (Client)\n    participant Client\n    participant Server\n    participant MessageHandler (Server)\n\n    MessageHandler (Client) -\u003e\u003e Client: Craft JSON message\n    Client-\u003e\u003eServer: Send (via socket)\n    Server-\u003e\u003eMessageHandler (Server): Receive message\n    MessageHandler (Server)-\u003e\u003eMessageHandler (Server): Parse message\n    MessageHandler (Server)-\u003e\u003eServer: Handle message (based on type)\n    Server-\u003e\u003eServer: Process at the server\n    Server-\u003e\u003eMessageHandler (Server): Return response\n    MessageHandler (Server)-\u003e\u003eServer: Craft JSON message\n    Server-\u003e\u003eClient: Send back (via socket)\n    Client-\u003e\u003eMessageHandler (Client): Receive message\n    MessageHandler (Client)-\u003e\u003eMessageHandler (Client): Parse message\n    MessageHandler (Client)-\u003e\u003eClient: Handle message (based on type)\n    Client-\u003e\u003eClient: Process at the client\n    Client-\u003e\u003eMessageHandler (Client): Return response\n```\n\n## Message Handling\n\nMessages are handled in `MessageHandler.cpp`. The MessageHandler class parses incoming JSON messages, delegates processing to the appropriate functions, and crafts JSON responses.\n\n## Entity Models and Their Functions\n\n### Admin\n- `banPlayer(int player_id)`: Bans a player.\n- `viewPlayerList()`: Views the list of players.\n- `viewRoomList()`: Views the list of rooms.\n- `spectate(int game_session_id, int room_id)`: Spectates a game session.\n- `leaveGame(int room_id)`: Leaves a game.\n\n### CubeState\n\nRepresents the state of a Rubik's cube during a game session.\n\n### GameSession\n\n- `createPlayerGameSessions(const vector\u003cint\u003e\u0026 playerIds, int cube_state_id)`: Creates player game sessions.\n- `endGameSession(int player_id)`: Ends a game session.\n### Player\n\n- `createRoom(int max_players, int max_spectators)`: Creates a room.\n- `joinRoom(int room_id, const char* participant_type)`: Joins a room.\n- `viewRoomList()`: Views the list of available rooms.\n- `updateCubeFromClient(string current_cube)`: Updates the cube state from the client.\n\n### Room\n\n- `startGameSession(int game_session_id, int player_id, string initial_cube_state)`: Starts a game session.\n- `canStartGame()`: Checks if the game can start.\n- `initCubeState()`: Initializes the cube state.\n\n### RoomParticipant\n\n- `leaveRoom()`: Leaves a room.\n- `isReady(int room_id)`: Marks the participant as ready.\n\n### UserService\n\n- `signUp(const string\u0026 username, const string\u0026 password)`: Signs up a new user.\n- `signIn(const string\u0026 username, const string\u0026 password)`: Signs in an existing user.\n\n## Queries\n\nThe queries are defined in Query.cpp and include:\n\n- **Admin Queries**\n- **Player Queries**\n- **Room Queries**\n- **RoomParticipant Queries**\n- **GameSession Queries**\n- **PlayerGameSession Queries**\n- **CubeState Queries**\n- **GameMove Queries**\n- **View and Index Definitions**\n\n## Database\n\nThe database schema and queries are defined in `Query.cpp`. The database file is located at `Rubik.db`.\n\n## Constants\n\nConstants are defined in `Const.h` and include enums for player status, room status, room participant status, game session status, player game session status, and validation status. ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftiuphun%2Frubik","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftiuphun%2Frubik","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftiuphun%2Frubik/lists"}