- When in the /.openapi-generator/ folder, run
npm run generate
- This will generate the cpp files in the /Source/PlayerClient/ folder.
- Additionally, it will run
generate-unreal-header.mjs
if you have node.js installed which will create a header file at /BeamSdk/Public/BeamPlayerClientAPI.h
An example implementation compatible with versions of Unreal newer than 5.2.1 is provided at: beam-sdk-unreal-example
Initialize a BeamClient to interact with the Beam API.
BeamStorage = UBeamSaveGameStorage::LoadOrCreate();
BeamClient = NewObject<UBeamClient>(this)
->SetBeamApiKey(BeamApiKey) // Required
->SetEnvironment(EBeamEnvironment::Testnet) // Optional, defaults to testnet if not set
->SetDebugLogging(true) // Optional, defaults to false if not set
->SetStorage(BeamStorage); // Required: Defaults to an Unreal SaveGame if you don't provide your own implementation
BeamStorage->Save();
BeamClient->GetActiveSessionAsync(EntityId, ChainId)
.Next([&, Callback](const BeamOperationResult& Response) {
// Do something with response
});
BeamClient->CreateSessionAsync(EntityId)
.Next([&, Callback](const BeamSessionResult& Response) {
// Do something with response
});
BeamClient->RevokeSessionAsync(EntityId, SessionAddress)
.Next([&, Callback](const BeamOperationResult& Response) {
// Do something with response
});
Beam sometimes has to open a browser in order for the user to sign in to a Beam account and sign transactions/sessions. By default we call FPlatformProcess::LaunchURL()
.
In some cases you might want to implement your own way of opening URLs, f.e. using a built-in WebView. To do so, you need to override FString UBeamClient::LaunchURL(const FString& Url)
in your implementation.