Multiplayer matchmaking/game server with TCP/IP
-
Clone the repository to your local machine:
git clone https://https://github.com/batuberksahin/PGameServer.git
-
Build the project using the provided build scripts:
For Windows you can run in your terminal:
build.bat
For Linux you can run in your terminal:
./build.sh
-
Port Forwarding:
In order for clients to connect to the game server from other devices on the local network, you'll need to set up port forwarding on your router. Forward the port used by the game server (13312 for MasterServer & GameServer port depends but default 13313) to the internal IP address of the machine running the server.
-
Firewall Settings (Windows Only):
If you're running the game server on a Windows machine, make sure to adjust the firewall settings to allow incoming connections on the port used by the game server (13312 for MasterServer & GameServer port depends but default 13313).
-
Connection:
You can find out the IP address required to connect to the servers from the client by typing "ipconfig" in the terminal for Windows or "ifconfig" for Linux based operating systems and looking at the IPv4 Address of the Ethernet adapter in use.
- You need to start MasterServer before GameServer.
- Multiple GameServers is acceptable.
The project is designed using a microservices architecture, consisting of the following main components:
The Game Server is responsible for handling client connections and managing the game logic. It communicates with the players and synchronizes game state across all connected clients. The Game Server uses the Repository Library to interact with the database and store game-related data, such as player information and game scores.
The Master Server acts as a central hub for managing game server instances and player matchmaking. It keeps track of available game servers and their current player capacities. When a player wants to join a game, the Master Server assigns them to an appropriate game server based on factors like region and player count.
The Repository Library provides a convenient interface for the Game Server and Master Server to interact with the database. It encapsulates database operations, such as saving and retrieving game-related data, behind a simple API. This helps keep the server code clean and maintainable.
You can contact me via batuberkshn[at]gmail.com