Part 2 of Embed with an iframe. Start your Eagle 3D Streaming multiplayer dedicated server only when someone comes to play — instead of keeping one running all day and paying for it — and let the game join it by itself. This works with Unreal's standard multiplayer: no extra code in your game.
A player opens your web page
|
|-- 1. is a server already running? --- yes --> use its address
| |
| no --> 2. start one, get its address
|
'-- 3. open the game with that address in the link
?commandLineArgs=-ExecCmds="open IP:port"
--> the game starts and joins the server. The player does nothing.
MyGameServer) is used below.
Unreal can run a console command when it starts. The console command open IP:port connects the game
to a server. So adding this to your game's link makes it join that server straight away:
?commandLineArgs=-ExecCmds="open 203.0.113.10:7777"
The whole link then looks like this:
https://connector.eagle3dstreaming.com/v5/YourName/YourGame/YourProject?commandLineArgs=-ExecCmds="open 203.0.113.10:7777"
| Part | What it is |
|---|---|
https://connector.eagle3dstreaming.com/v5/YourName/YourGame/YourProject |
Your stream link - the same link you already share. |
?commandLineArgs= |
Adds start options to your game (the Windows client) for this one viewer. |
-ExecCmds="..." |
An Unreal start option: everything between the quotes is run as console commands as soon as the game starts. |
open 203.0.113.10:7777 |
The console command itself: connect to the multiplayer dedicated server at this address. |
More than one console command: put them all inside the same quotes, separated by commas. For example, connect and also show the frame rate on screen:
?commandLineArgs=-ExecCmds="open 203.0.113.10:7777, stat fps"
These options are for your game (the Windows client). Your server gets its own start
options through the start call in step 3 ("commandLine") - for example the map it plays, see
Extra - play a specific map.
Try it once by hand before writing any code:
https://connector.eagle3dstreaming.com/v5/YourName/YourGame/YourProject?commandLineArgs=-ExecCmds="open 203.0.113.10:7777"
Put your own link and your server's address in it, and paste it into the browser.Your page talks to our API with three simple calls: list the running servers, start one, stop one.
Every call carries your API key. Find it in the Control Panel → Developer Section → API Key (see API keys and tokens), and send it in this header with each call:
Authorization: Bearer YOUR_API_KEY
Without it the answer is 401 unauthorized.
| To | Call | Answer |
|---|---|---|
| List running servers | GET https://agw.eagle3dstreaming.com/v1/multiplayer-dedicated-servers?app=MyGameServer |
|
| Start a server | POST https://agw.eagle3dstreaming.com/v1/multiplayer-dedicated-serversbody {"app": "MyGameServer"} |
|
| Stop a server | DELETE https://agw.eagle3dstreaming.com/v1/multiplayer-dedicated-servers/203.0.113.10-7777?app=MyGameServer |
|
Method and URL
GET https://agw.eagle3dstreaming.com/v1/multiplayer-dedicated-servers?app=MyGameServer
Header
Authorization: Bearer YOUR_API_KEY
What you send: only app in the URL - your server's name under Multiplayer Server Apps.
What you get back - every running server of that app:
{
"items": [
{
"id": "203.0.113.10-7777",
"app": "MyGameServer",
"version": "2",
"ip": "203.0.113.10",
"port": 7777,
"address": "203.0.113.10:7777",
"players": 0
}
]
}
No server running: "items" is an empty list, []. Use address to join, and id to stop it.
Try it from a terminal
curl "https://agw.eagle3dstreaming.com/v1/multiplayer-dedicated-servers?app=MyGameServer" \
-H "Authorization: Bearer YOUR_API_KEY"
Method and URL
POST https://agw.eagle3dstreaming.com/v1/multiplayer-dedicated-servers
Headers
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
What you send (the body):
{
"app": "MyGameServer"
}
If your server needs its own start arguments (a map, a match name), add "commandLine": "...", written exactly as you would type them after the server's .exe.
What you get back when the server is up:
{
"id": "203.0.113.10-7777",
"app": "MyGameServer",
"version": "2",
"ip": "203.0.113.10",
"port": 7777,
"address": "203.0.113.10:7777",
"players": 0,
"status": "running"
}
Or, while a first start is still being prepared (see "If the start answers starting" below):
{
"app": "MyGameServer",
"status": "starting",
"checkEverySeconds": 10
}
Try it from a terminal
curl -X POST "https://agw.eagle3dstreaming.com/v1/multiplayer-dedicated-servers" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"app": "MyGameServer"}'
Method and URL - the id from the list goes in the URL:
DELETE https://agw.eagle3dstreaming.com/v1/multiplayer-dedicated-servers/203.0.113.10-7777?app=MyGameServer
Header
Authorization: Bearer YOUR_API_KEY
What you send: the server's id in the URL, and app - your server's name.
What you get back:
{
"id": "203.0.113.10-7777",
"app": "MyGameServer",
"status": "stopping"
}
A server that is no longer running answers 404 server_not_found.
Try it from a terminal
curl -X DELETE "https://agw.eagle3dstreaming.com/v1/multiplayer-dedicated-servers/203.0.113.10-7777?app=MyGameServer" \
-H "Authorization: Bearer YOUR_API_KEY"
The first time a server machine starts your server, it downloads and unpacks it first. Then the start call
answers "status":"starting" instead of an address. Eagle 3D Streaming is working on making this
faster. Until then: do not start again — call the list every 10 seconds until the server
appears (usually within a few minutes). Starting twice would give you two servers and split your players.
Change the three values at the top and open the page.
<!doctype html>
<html>
<head><meta charset="utf-8"><title>Play</title></head>
<body style="margin:0;background:#000;color:#fff;font-family:sans-serif">
<p id="status" style="position:absolute;top:8px;left:12px">Getting the game server ready...</p>
<iframe id="game" allow="autoplay; fullscreen; microphone" style="width:100vw;height:100vh;border:0"></iframe>
<script>
// ---- change these three ----
const API_KEY = "YOUR_API_KEY"; // private test pages only - see the warning above
const SERVER_APP = "MyGameServer"; // your server's name under Multiplayer Server Apps
const GAME_LINK = "https://connector.eagle3dstreaming.com/v5/YourName/YourGame/YourProject";
const API = "https://agw.eagle3dstreaming.com/v1/multiplayer-dedicated-servers";
const say = (t) => { document.getElementById("status").textContent = t; };
const wait = (ms) => new Promise((r) => setTimeout(r, ms));
async function api(method, url, body) {
const r = await fetch(url, {
method,
headers: { "Authorization": "Bearer " + API_KEY, "Content-Type": "application/json" },
body: body ? JSON.stringify(body) : undefined
});
const data = await r.json();
if (!r.ok) throw new Error((data.error && data.error.message) || ("HTTP " + r.status));
return data;
}
async function getServer() {
// 1. a server already running? use it
let list = await api("GET", API + "?app=" + SERVER_APP);
if (list.items.length) return list.items[0];
// 2. none: start one
say("Starting the game server...");
const started = await api("POST", API, { app: SERVER_APP });
if (started.status === "running") return started;
// first start still preparing: wait for it in the list - never start a second one
for (let i = 1; i <= 30; i++) {
await wait(10000);
say("Getting the game server ready... (" + i * 10 + " s)");
list = await api("GET", API + "?app=" + SERVER_APP);
if (list.items.length) return list.items[0];
}
throw new Error("the server did not come up");
}
(async () => {
try {
const server = await getServer();
say("Server ready - starting the game...");
// 3. open the game with the server's address: Unreal runs "open IP:port" at start
const join = '-ExecCmds="open ' + server.address + '"';
document.getElementById("game").src =
GAME_LINK + (GAME_LINK.includes("?") ? "&" : "?") + "commandLineArgs=" + encodeURIComponent(join);
} catch (e) {
console.error("could not get a game server:", e);
say("The game server could not be started. Please reload the page in a minute.");
}
})();
</script>
</body>
</html>
A running server costs you while it runs. When your players are done, stop it with the
stop call and the id from the list.
| What you see | What it usually means |
|---|---|
Start answers "starting" | A first start is still downloading and unpacking. Keep calling the list; do not start again. |
| The list stays empty for many minutes | The server may be failing at start. Start it once from the Control Panel and look at its status there. |
| The game starts but does not join | Try step 2 by hand with the address from the Running list. If that works, compare the link your page builds. |
| Players end up on different servers | A second server was started while the first was still coming up - see "If the start answers starting". |
401 unauthorized | The API key is missing or wrong: header Authorization: Bearer YOUR_API_KEY. |
Say your game has a map called MyMap1 and this match should be played on it. Server and game must be on
the same map - and the server decides: a game that joins a server always loads the map the server is
playing.
commandLine, the way you
would type it after the server's .exe:
{
"app": "MyGameServer",
"commandLine": "/Game/Maps/MyMap1"
}
Use your map's own path (/Game/..., as in your project's Content folder). More server options go after
it, separated by spaces, e.g. "/Game/Maps/MyMap1 -log".
https://connector.eagle3dstreaming.com/v5/YourName/YourGame/YourProject?commandLineArgs=-ExecCmds="open 203.0.113.10:7777"
The game connects and loads MyMap1 by itself. Do not add open MyMap1 to the game's
commands: it is a second open and would replace the connect.
The map must be packaged in both builds - the server build and the game build (Project Settings → Packaging → List of maps to include). A map missing from either build cannot be loaded.
Last updated