Connection, Authentication, and Sessions
UCrowdControlSubsystem owns the native DLL, WebSocket connection, authentication, subscription, and game session. It is a game-instance subsystem, so use the same instance throughout a play session.
Get the Subsystem
In Blueprint, get the Game Instance and use Get Subsystem (Crowd Control Subsystem). Store the result in your login widget, player controller, or another object that persists long enough to receive events.
In C++:
UCrowdControlSubsystem* CrowdControl =
GetGameInstance()->GetSubsystem<UCrowdControlSubsystem>();Bind Events Before Connecting
Bind these events before calling Connect:
| Event | Use |
|---|---|
| On Auth Code Received | Receives the short Code and authorization URL. Display both and provide a button that opens the URL. |
| On Connection State Changed | Drives connection UI with the typed ECrowdControlConnectionState values. |
| On Session Ready | Runs once when authentication and subscription are complete. Register effects here. |
OnCommandIDChanged exposes the same state as integers (0 connecting, 1 disconnected, 2 waiting for login, 3 connected), but new Blueprints should use OnConnectionStateChanged.
Connect and Authorize
- Set a valid
ApplicationIDin CrowdControlSettings. - Call Connect.
- If the DLL has a valid cached token, it reuses or refreshes it and continues without prompting.
- Otherwise, the state becomes WaitingForLogin and the DLL requests an authorization code automatically.
- When OnAuthCodeReceived fires, show its
CodeandURL. Use Unreal's Launch URL node for an Authorize button. The URL may also be encoded as a QR code by your UI. - The user opens the URL, enters or confirms the code, and authorizes the application.
- The DLL redeems the code with PKCE, caches the JWT, subscribes, and starts a game session when automatic session start is enabled.
- OnSessionReady fires when the subsystem reaches Connected.
Call Request Auth Code to replace an expired or dismissed code. It requires both an active connection and a configured ApplicationID.
WARNING
LoginTwitch, LoginYoutube, and LoginDiscord are deprecated in the Unreal API. In the current plugin they all forward to RequestAuthCode; they no longer select a platform-specific login flow.
Connection UI States
Recommended UI behavior:
| State | UI |
|---|---|
| Disconnected | Show Connect and the most recent error/log guidance. |
| Connecting | Disable repeated connection attempts and show progress. |
| WaitingForLogin | Show the code, authorization URL, Open URL, and Request New Code. |
| Connected | Hide authorization controls and show Disconnect or session status. |
IsConnected means the transport reached the login stage or later. IsInitialized means the subsystem is authenticated, subscribed, and ready for effect setup and responses.
Register Effects Only When Ready
SetupEffect, SetupTimedEffect, SetupParameterEffect, and effect cloning require IsInitialized to be true. Call them from OnSessionReady, not immediately after Connect and not from an arbitrary BeginPlay.
For a level-placed CrowdControlEffectComponent, disable Auto Register and call its Register function from OnSessionReady. Auto-registration is appropriate only when the component begins play after the subsystem is already initialized.
Automatic or Manual Sessions
With Start Session Automatically enabled, no additional session node is required.
For games that need an explicit playable window:
- Disable Start Session Automatically.
- Connect and authorize normally.
- Call Start Game Session when gameplay begins.
- Call Stop Game Session when the run, match, or save ends.
Connection readiness and a running game session are separate concerns in manual mode.
Disconnecting and Reconnecting
- Disconnect stops the plugin's connection runnable.
- Reset Connection resets the DLL's raw command state.
- A later Connect starts the connection again.
Always make your event-binding and effect-registration flow safe to run again, because reconnecting can fire OnSessionReady another time.
Next Step
Create a basic effect with an effect component.
