Skip to content

Containerized unity game server with web api for creating multiple instances.

License

Notifications You must be signed in to change notification settings

ArtemVetik/docker-gameserver-factory

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Docker Game Server Factory

About

This project contains C# WebApi for creating multiple game servers and connecting to them using join codes. Servers can be created by clients from different platforms, including WebGL. The project uses Sql Server to store join codes and information about created servers. Each game server instance is open on ports 7777 and 7778 so that WebGL clients can connect with other platforms.

Usage

docker compose build

# Starts all services except gameserver
docker compose up -d --scale gameserver=0

This command will launch WebApi and SqlServer. Game servers should be started using REST requests to WebApi. The .env file contains the PROJECT_NAME and NETWORK constants. If you want to have several different games on the same virtual machine, make unique constants for each game.

API

API Description Request body Response body
POST /createserver Creates a server instance None Join Code
POST /connect/{joinCode} Provides server info by code None Server in JSON format
GET /connect Get all servers None Array of servers in JSON format
POST /removeserver/{id} Delete server None None

Note

POST /removeserver/{id} can only be called from Private Address Space. This is to ensure that servers cannot be deleted from the outside. This method can be called by your created server, for example, when all players are disconnected.

Build from Source

In Unity, go to Build Settings, change the platform to Dedicated Server (Linux) and build. The server build should be in the Server/build folder and named serverbuild.x86_64.

Usage for Mirror

This package contains a custom NetworkManager that automatically removes a server when needed, and a C# API for creating and connecting to servers.

About

Containerized unity game server with web api for creating multiple instances.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published