The Beamable SDK is structured as a collection of custom UE Engine, Editor and GameInstance Subsystems. Game-Maker Code (as in, code the Beamable customer writes) can take advantage of various guarantees we provide by understanding how these subsystems work.
The Beamble SDK authentication model is built around the concept of a
UserSlot. It functions as a named local player slot. At the moment, this does not integrate with UE's own LocalPlayer systems but... its likely that it will eventually.
By default, we ship with two lists of User Slots inside the
Project Settings -> Engine) :
RuntimeUserSlots, that contains a default slot at index 0, called
- This list is the list of expected player slots for every running client of your game.
EditorUserSlots, that contains a default slot at index 0, called
- The Beamable Editor integration also uses the user slot system to authenticate the requests it makes to the Beamable servers. So... when you signed into the editor, you're data is associated to this default slot.
The point of this is to allow our SDK to be compatible with local co-op games that also want to make use of Beamable features with per-player granularity. As in, allow local players 1 and 2 to log into their respective accounts.
UBeamUserSlotsEngine Subsystem is responsible for:
- Namespace slots in order to support multiple running PIE instances. This is why, like UE, we take in a
UObject* CallingContextparameter in certain parts of our APIs.
- Association of arbitrary data with these namespaced slots.
- Assert that only slots defined in the
UBeamCoreSettingsare in use.
- Except any User Slot with
Testin its name. So you can write automated tests with arbitrary amounts of user slots by using user slots with
Testin their names.
This subsystem does not handle the actual logging in and logging out. That is handled by two other Subsystems:
GameInstanceSubsystem, is responsible for PIE instances and packaged games.
EditorSubsystem, is responsible for the Editor integration.
For now, we will focus on the
UBeamRuntimesubsystem. For more information on the editor integration, look at [[Unreal SDK - Editor Integration]].
UBeamRuntime is the entry point for the Beamable SDK at runtime. It is a
GameInstanceSubsystem and follows its lifecycle rules. It is responsible for a couple of things:
It controls the SDK's runtime initialization flow.
It controls the various SDK's user [un]-authentication flows.
UBeamRuntimeSubsystems'slifecycle with respect to the SDK itself and
The images below describes how the Beamable SDK's lifecycle injects itself into UE's own lifecycle:
Now that you understand the SDK's initialization flows, read up on the various Sign Up and Login flows we provide.
The Beamable SDK comes with a set of pre-implemented operations for common sign-up use-cases. Here are how to set up a few of the common login/signup flows using Beamable.
By default, the SDK comes configured with Frictionless Authentication turned on. This is to make testing easier and allow for easy experimentation. Also, this is the default behavior in mobile-first titles.
With this on, after
UBeamRuntime::OnStarted has run, we'll attempt to automatically create a guest account for you, at the first configured
FUserSlot. If an account is already locally cached at that
FUserSlot we'll login to that one automatically.
At the moment, there's not much automatic error handling for this path and we don't recommend shipping with it on for now (its mostly there to make it easy to get started and experiment with the SDK).
With Frictionless Auth turned on, you can add delegates to
UBeamRuntime::OnUserReady and start using the SDK there as a
guest Beamable user. Guest users will be lost if signed out (or have its locally cached data lost for any reason).
At any point once signed in, you can attach a different identity to them through one of the various
UBeamRuntime::Attach_____ Operations. Once that is done, that account can now be accessed through the
UBeamRuntime::Login____ Operation for the type of credentials you attached. For example, if you
AttachEmailAndPassword you'll be able to
LoginEmailAndPassword to sign back into the account.
By default, this does not run in Dedicated Servers even if it is on. Dedicated Servers use a different form of authentication.
In PC/Console titles, often the user can sign-in and up from inside the game. That can happen either through an active form-filling process, an active request to third-party authentication (Discord, Google, etc...) or an automatic store-based login (Epic Online Services, PSN, Steam, etc...).
If your game has these flows, we recommend you disable frictionless auth and manage the login/signup flows yourself.
Start by turning off Frictionless Authentication in
Project Settings > Beamable Core > Authenticate Frictionless (...).
Then, in your
BeginPlay implementation, register a function to run when the SDK has successfully started via
UBeamRuntime::RegisterOnStarted. If the SDK has already started when you call this function, it'll run the callback you provide it as its parameter immediately; if not, it'll wait until the SDK is fully ready and then call it.
At any point during or after that callback, make a call to one of the
UBeamRuntime::Login____ Operations with the appropriate parameters for the flow you want.
We treat these operations as atomic inside the SDK and will clear any invalid partial state in case of any failure during their internal multi-step process; triggering
UBeamRuntime::OnUserReady only in the case that the user is fully ready for use.
The Beamable SDK comes packaged with a set of stateful subsystems to make it simpler to leverage our APIs. Basically, we write generalized implementations of useful systems on top of our APIs so that:
- You don't have to set up the common case.
- You can use them and their extension points for variations of the common case.
- You can use them as reference implementations to implement your own custom use cases outside of the common case.
These are hand-written and, currently, are comprised of:
UBeamContentSubsystem: This leverages the Beamable Content system to receive dynamic updates to read-only game data definition; also supports baked in-build content through the same API.
UBeamInventorySubsystem: This provides builder functions around our Inventory APIs that allows you to combine what would be multiple API requests into a single batched inventory update. It also receives inventory notifications coming from the server and keeps those in sync.
UBeamMatchmakingSubsystem: This provides you a stateful way of joining/canceling a matchmaking queue and receiving updates when a match is found.
These systems make use of the various
UBeamRuntime::____callbacks to keep their state correct and expose hooks and configuration options for Game-Maker Code to run with semantically relevant guarantees.
If the exposed hooks on these are not enough for your use case and constraints, as a user you can create your own
UBeamRuntimeSubsystem. The SDK tries not to hide things from you so you can use the provided
UBeamRuntimeSubsystemsto understand how they are set up when creating your own. The documentation in [[Unreal SDK - Runtime Concepts#Lower-Level SDK Subsystems]] can also be useful when implementing your own
That being said, for most common use-cases, the hooks, provided implementations and the use of Beamable Microservices are likely to be enough to facilitate whatever behavior you need.
This section talks about lower-level details of how requests to Beamable get made. You don't need to read this, but... you might want to anyway.
The lowest layer of systems are shared between the SDK's UE Editor integration and the SDK's Runtime integration:
UBeamUserSlots: As explained at the start of this document, tracks multiple local signed-in users (for local co-op cases).
UBeam_____Api: Code-Generated Subsystems from our Backend OpenAPI spec.
- These are stateless subsystems.
- These provides you low-level access to every end-point of our backend even if we don't have utilities in the SDK that do exactly what you want.
- As UE doesn't allow for namespaces AND BP-compatibility, this is verbose. We recommend more liberal use of
autowhen dealing with Code-Gen API Types.
UBeamBackend: Contains BP-Compatible and Lambda compatible implementations of Request/Response handling functions. It handles:
- Request/Response serialization and deserialization.
- Configurable Retry Logic. Request, User and call-site granularity.
- Transparent and Automatic Re-Auth in case of expired
AccessTokenthrough a user's
LogBeamBackend Verbosealso is a useful diagnostic tool as it will print out the entire process of building the request, sending it out and receiving its response.
- Safely ignore handle requests that were made during PIE but whose response arrives after the PIE world has been deconstructed.
UBeam_____Notifications: Leverages UE's WebSocket implementation and associates different web-socket connections with different user slots.
UBeam_____Notificationsare implemented per Beamable backend system (inventory, stats, etc...) to expose two UE function versions, one BP-Compatible and the other Lambda-Compatible, that register a handler to process a specific type of notification.
- These are used by
UBeamRuntimeSubsystembased on their semantic needs. For example,
UBeamMatchmakingNotificationto subscribe to notifications for the matchmaking ticket it got for joining a queue so it can react to a match that was made.
UBeamRequestTracker: A BP-compatible implementation of Async Operations that can emit various Events as it goes along --- you can think of these as "BP-Compatible Promises".
- These are integrated with our
BeginOperationis effectively the same a creating a new promise.
TriggerOperationCancelledshould be called when you want to complete the Operation.
- This is a somewhat complex subsystem so we recommend you read its comments in full if you want to write your own operations.
The systems above are used by various environments the Beamable SDK runs in: PIE, Editor, Dedicated Server Builds and regular game builds. Their code is pretty heavily commented and complex; still, feel free to read it and figure things out that way.
Updated about 2 months ago