{"id":20332490,"url":"https://github.com/permutationlock/simple_web_game_server","last_synced_at":"2025-07-28T21:08:39.630Z","repository":{"id":95722265,"uuid":"303240576","full_name":"permutationlock/simple_web_game_server","owner":"permutationlock","description":"A C++ library for creating authenticated scalable backends for multiplayer web games.","archived":false,"fork":false,"pushed_at":"2025-04-09T10:09:30.000Z","size":2322,"stargazers_count":7,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-11T21:38:48.496Z","etag":null,"topics":["cpp-library","game-server","game-servers","javascript","jwt-authentication","matchmaking-servers","websockets"],"latest_commit_sha":null,"homepage":"https://permutationlock.com/simple_web_game_server/","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/permutationlock.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.MIT","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,"zenodo":null}},"created_at":"2020-10-12T00:42:52.000Z","updated_at":"2025-04-09T10:09:33.000Z","dependencies_parsed_at":"2025-04-11T21:46:12.660Z","dependency_job_id":null,"html_url":"https://github.com/permutationlock/simple_web_game_server","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/permutationlock/simple_web_game_server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/permutationlock%2Fsimple_web_game_server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/permutationlock%2Fsimple_web_game_server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/permutationlock%2Fsimple_web_game_server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/permutationlock%2Fsimple_web_game_server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/permutationlock","download_url":"https://codeload.github.com/permutationlock/simple_web_game_server/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/permutationlock%2Fsimple_web_game_server/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267585659,"owners_count":24111576,"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","status":"online","status_checked_at":"2025-07-28T02:00:09.689Z","response_time":68,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["cpp-library","game-server","game-servers","javascript","jwt-authentication","matchmaking-servers","websockets"],"created_at":"2024-11-14T20:26:52.527Z","updated_at":"2025-07-28T21:08:39.577Z","avatar_url":"https://github.com/permutationlock.png","language":"C++","readme":"### Simple Web Game Server\n\n*Disclaimer: I have learned a lot since I originally created this library, and I\nwould not recommend it for anything other than educational purposes. The library\nshould still work though, and I used it to host a game server for ~2 years of\ncontinuous uptime with no issues.*\n\nThis project provides generic C++ classes to create multi-threaded game servers\nand matchmaking servers for browser games using WebSockets and JWT\nauthentication. It is built\nupon the [WebSocket++](https://github.com/zaphoyd/websocketpp) and\n[JWT++](https://github.com/Thalhammer/jwt-cpp) libraries.\n\nThe source code is available on\n[GitHub](https://github.com/permutationlock/simple_web_game_server).\n[Doxygen](https://www.doxygen.nl/index.html) documentation is available\n[here](https://permutationlock.com/simple_web_game_server/).\n\n#### Dependencies\n\nYou must have a C++17 compatible compiler, and `libcrypto` and\n`libssl` system libraries.\n\n#### Motivation\n\nThe core motivation for the libarary is to:\n\n - provide a C++ framework for creating servers to run online multiplayer\n   browser games and to perform algorithmic matchmaking;\n - be flexible and simple by providing as little as possible\n   beyond the core functions;\n - be secure and authenticate clients in order to support competitive games;\n - have servers run independently with no external communication\n   beyond messages to clients;\n - be performant and allow both horizontal and vertical scaling.\n\nIn order to create a backend for a game,\nall that needs to be written is a specification for the JWTs that you want to\nverify, a class describing the game logic, and a class detailing the\nmatchmaking algorithm; see examples below.\n\nSecurity is achieved by via TLS and the WSS protocol. Clients must also\ninitiate each connection to the server with a JWT\ncontaining their identity and detailing\ntheir intended session with the server.\n\nWith regards point four and server isolation, the servers in this\nlibrary are designed to only listen and communicate to clients, and to\nmake no other external communication, such as updating a databases.\nEach time a server session is completed, the server will send each\nassociated client a token verifying the result. Thus, if it is desired that server\nactivity be tracked, for example to track ranked matches in a\ncompetitive game, each client may be designed to submit their result tokens to a\ncentral location for tracking. In order to guard against\nmalicious clients there must be significant incentive for clients to\nsubmit their results, but this will usually exist\nnaturally, e.g. the winner in a competitive game will always wish to\nsubmit the result.\n\nSince servers run completely independently, it is easy to achieve horizontal\nscaling by simply spinning up as many servers as desired and then pointing new\nclients to them with the appropriate JWT authentication.\n\nVertical scaling is accommodated by allowing for multi-threading in several\naspects of the server: multiple threads may be assigned to handle WebSocket\nconnections and server\nactions, and the game update loop may update games in\nparallel.\nIn general the most benefit from parallelization\nshould come from processing game updates.\n\n#### Examples\n\n - [Minimal Template](https://github.com/permutationlock/simple_web_game_server/tree/main/examples/minimal_template):\n   minimal examples of game and matchmaking servers, with and without TLS.\n - [Tic Tac Toe](https://github.com/permutationlock/simple_web_game_server/tree/main/examples/tic_tac_toe):\n   a full implementation of a competitive tic tac toe game with elo ranking,\n   matchmaking, and allowing for clients to reconnect to games.\n\n#### Basic functionality\n\nThe base server class wraps a\n[WebSocket++](https://github.com/zaphoyd/websocketpp) server and provides JWT\nauthentication as well as player and session identification for clients.\nA player id is an identifier unique to each player while a session id is unique\nto a particular session of interaction with the server.\n\nWhen the first client with a given session id connects and provides a verified\nJWT, a session is started. Each\nsession persists until it is ended by the server, at which point a result\ntoken string is sent back to all participating clients.\nCompleted sessions are archived for a period of\ntime to allow clients to retrieve the result token; this allows\ndisconnected players to reconnect and see the result of a game for example.\n\nIn a game server a session represents a particular\ngame, with different players sharing the same session id if they are in the\nsame game. In a matchmaking server sessions have multiple potential uses\ndepending on the specification, e.g. allowing multiple players to queue for\na match together by sharing a session.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpermutationlock%2Fsimple_web_game_server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpermutationlock%2Fsimple_web_game_server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpermutationlock%2Fsimple_web_game_server/lists"}