# Ship a game

Choose who runs the input host before you build your release. Keep the SDK files fixed, serve secure connections and plan for a room ending. A working source example does not establish engine export or phone hardware support.

## Contents

- [Who runs what](#who-runs-what)
- [Pin the SDK](#pin-the-sdk)
- [TLS and browser origins](#tls-and-browser-origins)
- [Room lifetime and ownership](#room-lifetime-and-ownership)
- [Message and service limits](#message-and-service-limits)
- [One Pro player in a room](#one-pro-player-in-a-room)
- [When a connection or service fails](#when-a-connection-or-service-fails)
- [Updates and compatibility](#updates-and-compatibility)
- [Release check](#release-check)

## Who runs what

**Hosted browser room — `createRoom`.** You serve the game page and its SDK files. Controller+ operates the room service and rendezvous socket. Each phone joins that service. Input can move to a WebRTC peer link; when no direct path works it stays on our relay, and for a Pro player Cloudflare's TURN relay can carry it. Views, public state and signaling still need the host socket. Phones open the controller from controller.plus, so they run its current version ([what stays live](#pin-the-sdk)). The desktop app is not required.

**Your own host — `ControllerHost`.** You run Node on a reachable computer or server. It serves the phone controller, QR and WebSocket endpoint. A browser game can run its simulation there. A Godot, Unity, Unreal or Python game connects separately with host authority. You must start, supervise and stop both processes. Local touch play can work without internet when all game, phone and feedback files are local. No Controller+ service is needed.

**Existing game — desktop app.** The companion sends compatible virtual-controller or game-key input to a game that has no SDK integration. It is a separate product path. An SDK game already receives input and private screens itself; installing the companion does not replace its host.

**What Controller+ receives from your players.** In a hosted room, phones open controller.plus's controller. It sends usage counts tied to a random ID kept in that phone's browser: the first time it opens, each join (scanned, linked or typed), minutes played, and mode and look changes. It sends no names, no input, and no IP address is stored with them; a browser with Global Privacy Control or Do Not Track sends nothing. The [privacy policy](https://controller.plus/privacy) has the details. A controller you serve yourself sends these counts to your own server's `/api/events`, which can simply answer 404.

The SDK sends controller input and private phone screens. Arrange a shared display or your own screen-sharing solution when distant players need to see the game.

Start with [Phaser](phaser-arena.md), [Node](quickstart.md), [Godot](godot.md), [Unity](unity.md) or [pygame](python.md). Read [engine readiness](integrations.md#engine-readiness) before choosing an export target.

## Pin the SDK

Install a specific downloaded SDK archive and keep it with your release inputs. Install from its actual filename:

```sh
npm install --save-exact /absolute/path/to/controller-plus-sdk-<version>.tgz
```

The archive carries the packages it needs, so installing it does not reach the npm registry, and there is no registry release to resolve for you. Use `npm ci` for later builds of your project. Keep the archive at the recorded path, or in a stable artifact location your build can reach; earlier versions stay on the [downloads page](https://controller.plus/downloads) with their checksums.

In a browser game, copy the archive's `src/` folder to your site and import it from there ([the steps](web-games.md#serve-a-pinned-copy)):

```js
import { createRoom } from './sdk/src/relay-host.mjs';
```

Importing `https://controller.plus/sdk/src/relay-host.mjs` is fine while you prototype, but it changes when we release; ship your own copy.

**What stays live.** Phones in a hosted room open the controller at controller.plus, so they always run its current version, whichever copy your game ships. Old games keep working: new protocol features are used only when both sides ask for them ([updates and compatibility](#updates-and-compatibility)). To fix the phone side too, serve the controller yourself: `serveControllerAssets` serves the package under `/sdk/` and its phone page at `/join`. For static hosting of the controller, copy the archive's `src/`, `web/`, `vendor/` and `assets/` together under `/sdk/` and expose `/sdk/web/controller.html` at `/join`; keep their relative paths. The controller imports sibling modules, styles and fonts, and built-in feedback uses the matching assets.

Keep one SDK copy across your game page, Node host and engine bindings. Build the Python/C shared library from that same source. The Phaser starter also needs its fixed Phaser file locally for offline play.

## TLS and browser origins

Use trusted HTTPS and WSS for internet play. Configure `origin` or `PUBLIC_ORIGIN` as the public HTTPS address, even if a reverse proxy talks HTTP to Node. Forward WebSocket upgrades to the same host. Keep `/ws`, `/join` and `/sdk/` on their expected paths.

For example, place this in the `http` context of an nginx configuration. Replace the hostname and certificate paths. Node listens on the private upstream port.

```nginx
map $http_upgrade $controller_connection {
    default upgrade;
    '' close;
}
server {
    listen 443 ssl;
    server_name game.example;
    ssl_certificate /absolute/path/to/fullchain.pem;
    ssl_certificate_key /absolute/path/to/private-key.pem;
    location / {
        proxy_pass http://127.0.0.1:49510;
        proxy_http_version 1.1;
        proxy_set_header Host $host;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $controller_connection;
        proxy_read_timeout 75s;
    }
}
```

Set `PUBLIC_ORIGIN=https://game.example` when starting the [Node example](quickstart.md). Protect the upstream port with your network configuration. If a separate browser origin hosts your game or custom controller, add that exact origin to `allowedOrigins`. An allowed origin still needs valid credentials. Do not use wildcard origins or ask players to disable browser security.

LAN HTTP works for touch input. Motion and in-page camera APIs can need trusted HTTPS and a permission gesture. See [local HTTPS](local-setup.md#motion-on-iphone). Native engine clients must trust the certificate too.

## Room lifetime and ownership

A `ControllerHost` instance owns one in-memory room. Its room, player IDs, private views, public state and resume tickets disappear when that process is replaced. The room expires six hours after creation. Disconnected seats remain reserved for five minutes and count toward `maxPlayers`. The default direct-host limit is 16; choose your game's limit explicitly.

Do not round-robin one room across independent Node processes. They do not share seats or tokens. Keep every socket for that room on its owning instance, or build an explicit room-owner router. Save your simulation separately if a restart must preserve a match. Recreating a host creates a new room and requires a new invitation.

For hosted rooms, use the creation response's `expires` value. `RelayRoom.close()` ends the service's room at once; `close({ keep: true })` leaves it open for a page that attaches to it again. The client has no room-renewal API. Handle `room_expired` by ending or saving the match, creating a replacement room and showing its new QR. Do not promise a room will remain available until expiry: a service failure or policy limit can end it sooner.

Removal invalidates that seat's resume ticket. A `ControllerHost` also issues a new invitation: update both the QR and the player link. A hosted room keeps its invitation, so a removed player can come back through the same QR as a new seat; to keep someone out, open a new room. Do not place the host token in a QR or link. A phone returning with a valid ticket keeps its `playerId`; a fresh tab can allocate another seat. See [players and reconnects](quickstart.md#players-and-reconnects).

## Message and service limits

- A hosted room defaults to eight phone seats, configurable to 1–16. Local physical gamepads are extra players; enforce your total player limit in the game.
- Private views and hosted public state each have a 14,000-byte JSON budget. Direct in-process `publish` allows 180,000 bytes. An engine's command still has to fit its envelope.
- Client JSON frames allow 16,384 bytes and 180 messages per second per socket. Schedule output across all players before sending it. Host coalescing does not undo an already exceeded socket budget.
- Input pacing is route-specific. Use `Session.input` rather than sending one frame per animation tick. See the exact [client pacing policies](sdk-client.md#pacing-and-limits).
- Hosted room creation can fail with `room_limit`, `rate_limited` or `service_unavailable`. One network address may hold 24 open rooms and create 30 in ten minutes ([rooms per network](sdk-relay-host.md#limits-and-reconnects)); per-connection limits are in the [protocol](protocol.md#host-specific-budgets). There are no account or traffic quotas beyond these. Handle a refusal, and test with the number of players you expect before a launch.

**Our hosted relay is free for games, with fair use.** Fair use means rooms that people play in: not a general-purpose relay, a load test or a stream of rooms nobody joins. A room lasts up to six hours and ends sooner when nobody is connected. A game that opens rooms much faster than people play in them is refused (`rate_limited`, `room_limit`) until it slows down. We announce in the [changelog](/sdk/CHANGELOG.md) and on [controller.plus/developers](https://controller.plus/developers), at least 90 days ahead, any change to the relay that would break a game that works today: shutting it down, charging for it, or changing what it speaks. There is no uptime guarantee: handle a refused or dropped room, or run your own host with `ControllerHost`. These terms are part of our [Terms of use](https://controller.plus/terms#hosted-relay-for-games).

Player Pro purchases do not pay for your own Node infrastructure. Read the included [SDK license](/sdk/LICENSE.md); it permits commercial game integration, with the restrictions stated there. Review the license included with the copy you distribute.

## One Pro player in a room

The hosted service decides the room's effective tier. One connected player with verified Pro can give the relayed room premium treatment for the group. Players do not each need Pro for that room's relay tier. Treat that as a current service policy, not a permanent entitlement stored in your game. If that player leaves, use the next service-reported tier.

Purchase verification and hosted tier policy belong to the service, whose implementation is outside this SDK. The observable client contract is the `tier` in welcome and state frames. With `premium`, socket analog input uses an 8 ms minimum interval instead of 16 ms, and when its direct link fails, Cloudflare's TURN relay can carry it (8 ms). A `standard` (free) room never uses TURN. This permits more frequent updates; it does not guarantee a frame rate or latency. Button edges have their own immediate-send behavior. Direct `lan` and `p2p` routes keep their existing policy and are not moved onto a relay. Your own `ControllerHost` reports `developer` and does not verify purchases or apply a room Pro upgrade.

Keep base input usable at either tier. Never trust a client boolean as proof of a purchase, and never place store credentials or verification secrets in a game build.

## When a connection or service fails

**Before a hosted room opens:** `createRoom` rejects. Show a failure message and an explicit Retry action. Do not keep showing scan instructions beside an empty QR. Initial connection failure is not automatically retried.

**After the host socket drops:** clear stored input and show reconnecting beside the existing players. The SDK closes its peer links too. An established peer input path is therefore not an independent offline session. Hosted views, state, new joins and reconnects all depend on that service connection.

**After reconnection:** reconcile from the current roster. RelayRoom automatically replays its saved current views after that snapshot. A phone still connected to the service may not emit another `join` when only the game host reconnects. Update views if your round changed during the outage, and register custom catalogs again. Do not replay past sound or rumble. Preserve score only for IDs still in the roster; delete permanently removed IDs.

**After an expired or invalid invitation:** stop retrying those credentials. Show the new QR and let the player rejoin. A host-page reload also loses any simulation stored only in that page.

**With your own host:** a vendor outage does not interrupt local touch play with locally served assets. Your own host, network and TLS must still be available. A host-process failure ends its room; it does not automatically migrate players to the hosted service. Keep a keyboard or other useful fallback when phone input is essential.

## Updates and compatibility

SDK package, app and engine versions are separate. The JSON protocol remains version 1; optional features are accepted through hello/welcome negotiation. Request only features your client implements. Unknown extensions are ignored. For older hosts, send a full view when `surface-patch` is unavailable and use arrival time when `input-time` is unavailable.

`requires.controller` can set a minimum iOS/Android app version. It does not pin the browser controller or SDK. A surface's `legacy` can supply a usable older-client view; `minApp` alone is not a room-wide version gate.

There is no long-term-support or automatic migration promise in the package. Update the host, browser assets and bindings together, then run the [simulated-phone checks](testing.md) and your game's lifecycle test before replacing a release. Keep the previous complete release available for rollback. Do not combine mismatched native structs and Python bindings.

## Release check

Verify two phones controlling distinct players, a held-input disconnect, reload into the same seat, permanent removal and the replacement QR. Test the actual exported engine target and real phones. Check denied motion/camera permission, muted output, sleep/background return and service loss. Give players visible feedback when sound or vibration is unavailable.

Use [developer troubleshooting](troubleshooting.md#troubleshooting-for-developers) for setup failures and the [reference](sdk-reference.md) for exact limits.

[All start pages](index.md) · [Search developer docs](search.md) · [Ship a game](shipping.md)
