Tutorial: pass a different value to your Unreal app for every visitor

Your Unreal app on Eagle 3D Streaming needs to know something different for every person who opens it: their name, their room, their company, a login token. On your own PC you might put that in an environment variable. On a streaming service you cannot — and you do not need to. The value travels in the stream link instead, and your web page writes a different link for each user. This article shows how, in plain steps.

Why not environment variables?

An environment variable belongs to the machine, not to one viewer. Our streaming machines are shared: the same machine serves different apps and different viewers through the day, so there is no place to set "this value, for this user, for this session". And a value set on a machine would apply to everyone who lands there.

The good news: anything a program reads from its environment it can read from its command line instead, and the command line is something you control per session — from the link.

The idea in one picture

your website knows who is logged in   (alice)
        |
        v
your page builds the link   .../YourProject?commandLineArgs=-username%3Dalice
        |
        v
iframe opens that link  ->  Eagle 3D Streaming starts your app with  -username=alice
        |
        v
your app reads  -username=  and knows it is Alice

One project, one app, one link pattern. Only the value at the end changes, and your page fills it in.

Step 1. Read the value in your app

Unreal reads command-line values with one line of C++. For -username=alice:

FString UserName;
if (FParse::Value(FCommandLine::Get(), TEXT("username="), UserName))
{
    // UserName is "alice"
}

Test it on your own PC first: start your packaged app with -username=alice after the exe name and check your app picks it up. If it works there, it works streamed.

Step 2. Put the value on the stream link

Add ?commandLineArgs= to the end of your project's stream link, followed by the parameters:

https://connector.eagle3dstreaming.com/v5/your-username/YourApp/YourProject?commandLineArgs=-username=alice

Open it in a browser and your app starts with -username=alice on its command line. Several values are separated by spaces, exactly as on a command line: -username=alice -room=12.

Step 3. Build the link for each user, in an iframe

On your website you already know who is logged in. Embed the stream in an iframe and set its src from code, so every user gets their own link:

<iframe id="stream" allow="autoplay; fullscreen; microphone" style="width:100%;height:600px;border:0"></iframe>

<script>
  const base = "https://connector.eagle3dstreaming.com/v5/your-username/YourApp/YourProject";
  const user = currentUser.name;   // from your own login
  const args = "-username=" + user + " -room=" + currentUser.room;

  document.getElementById("stream").src =
    base + "?commandLineArgs=" + encodeURIComponent(args);
</script>

encodeURIComponent turns spaces and other special characters into a form that survives the trip through the link. Without it, a &, # or + inside a value would cut your command line short. Your server-side page can do the same thing in any language — what matters is that the src is written per user, not hard-coded.

We tried exactly this link on our own streaming machine: the app was started with -username=alice -room=12 on its command line.

Good to know

SituationWhat happens
The link has no ?commandLineArgs=The app starts with the project's own Launch options, as always
The link has ?commandLineArgs= and the project's Append Parameters To URL is off (the default)The link's parameters replace the project's Launch options
Same, with Append Parameters To URL onThe project's Launch options come first, the link's parameters are added after
A value contains %Avoid it for now: a literal % does not arrive today

The full rules, with every special character, are on command-line parameters (advanced).

And the multiplayer server?

The values above are per viewer, so they belong on the viewer's app. A multiplayer dedicated server serves many viewers at once, so per-user values do not go there. Server-wide settings — the map, the number of players — are command-line parameters too: with our plugin, set them in its Command Line field.

Watch it in 13:38

The whole thing, start to finish, in Unreal Engine 5.8 with Blueprint only — no C++: the app reads -username= with Get Command Line and Parse Param Value, the link adds ?commandLineArgs=, and a small web page writes the link for each viewer.

Per-user values in the stream link - "Welcome, Alice!" (UE 5.8, Blueprint only)Video · 13:38

Related

Last updated