Skip to content

Magithar/socketio-unity-mirror-server

Repository files navigation

socketio-unity-mirror-server

Headless Unity/Mirror dedicated game server for socketio-unity that supports both native clients (KCP/UDP) and WebGL clients (WebSocket) simultaneously, deployed to Edgegap edge compute via Docker.

This repo is the dedicated server component. Clients (WebGL + Windows/Mac) and the Socket.IO lobby are in the socketio-unity repo.

How it fits together

Architecture

The lobby server on Render handles matchmaking and distributes the Edgegap server address to clients. This server handles Mirror game networking only — movement, state sync, player spawning. It does not do auth.

See documentation/architecture.md for the full topology and trust boundaries.

What's in this repo

Path Purpose
mirror-server-demo/ Unity 6.0 LTS project — build this to produce the server binary
Dockerfile Wraps the Linux server binary into an Ubuntu 22.04 image
.github/workflows/build-server.yml On release publish: downloads zip, builds Docker image, pushes to Edgegap registry
documentation/ Architecture, flows, permissions, and variables docs
SETUP.md Full end-to-end setup guide

Transports

Port Protocol Clients
7777/UDP KCP Windows / Mac native
7778/TCP WebSocket (TLS terminated by Edgegap) WebGL

Both run simultaneously via MultiplexTransport. Clients pick one based on platform.

Deploy

Full walkthrough in SETUP.md. The short version:

  1. Build — Unity → File → Build Profiles → Linux Server → Build
  2. Releasezip -j server-linux.zip <build-dir>/* → GitHub Release with zip attached
  3. CIbuild-server.yml automatically builds and pushes registry.edgegap.com/<org>/mirror-server:vX.X.X
  4. Edgegap — create a version in the dashboard, add the two ports above, deploy
  5. Render — update three env vars so the lobby server hands the new address to clients:
Variable Value
MIRROR_SERVER_ADDRESS <fqdn>.pr.edgegap.net
MIRROR_KCP_PORT external UDP port from Edgegap dashboard
MIRROR_WS_PORT external TCP/WS port from Edgegap dashboard

Render auto-redeploys on save. No client changes needed.

Connecting clients

In MirrorGameOrchestrator, set ServerMode before entering Play mode:

Client type ServerMode
Windows / Mac DedicatedKCP
WebGL DedicatedWebSocket
Local host (testing) PeerToPeer

GitHub secrets required

Secret Purpose
EDGEGAP_REGISTRY_USER Docker login to Edgegap registry
EDGEGAP_REGISTRY_TOKEN Docker login to Edgegap registry
EDGEGAP_ORG Org slug for image tag construction

Keeping scripts in sync

Four scripts are imported from com.magithar.socketio-unity as Package Manager samples and must be kept in sync with the client repo when updated:

LobbyStateStore · LobbyNetworkManager · LobbyUIController · MirrorGameOrchestrator

To update: copy changed files into Assets/Samples/Socket.IO Unity Client/1.4.0/, or remove and re-import the affected samples in Package Manager.

Known limitations

  • No Mirror-level auth. Any client that knows the Edgegap FQDN and port can connect without going through the lobby. Access is gated only by the secrecy of those values, which the lobby distributes via match_started. See documentation/permissions.md.
  • Free tier. Edgegap's Mirror-partner tier provides 1.5 vCPU per deployment. Stop deployments when not testing — idle deployments consume the allowance.
  • No automated rollback. A bad image push requires manually creating a new Edgegap version pointing to the previous tag.

Documentation

Related

About

Deployable Mirror dedicated server for socketio-unity — KCP + WebSocket via MultiplexTransport, Docker + GitHub Actions CI, hosted on Edgegap.

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages