This is a minimal peer-to-peer multiplayer lobby system built with the Godot game engine and a lightweight Flask backend.
The system allows players to host and join multiplayer sessions using short join codes, without needing to exchange IP addresses. The host's machine uses UPnP to open the required port, enabling connections across networks.
- Simple join-code based matchmaking
- UPnP port forwarding for external hosting
- Flask backend for lobby code registration and resolution
- Asynchronous networking logic using
await - Modular Godot client with clean autoload architecture
- UI for hosting, joining, and viewing synchronized players
You can run the backend locally or deploy it on a free platform like PythonAnywhere.
To set it up:
Copy the code from the file matchmaker-main.py into the your Flask server's main.py file.
The server will expose two endpoints:
/register– Host sends a POST request to receive a join code./resolve– Client sends a GET request with the code to resolve it to an IP address.
In the MultiplayerManager autoload script, set your server’s address:
const MATCHMAKING_SERVER_URL: String = "https://your-matchmaking-server.com"Replace the placeholder with the actual URL of your hosted Flask server.
- For external connections to work, UPnP must be enabled in your router settings.
- If UPnP is unavailable or disabled, the host will only support LAN connections.
Open the project in the Godot Engine, and run multiple instances to simulate multiple players. Use the UI to host or join games with generated lobby codes.
- Host a game using the "Host" tab – a 4-digit join code will be displayed and copied to clipboard.
- On another device or instance, input the code in the "Join" tab and connect.
MIT License