Unreal EnginePreview
A Game Instance Subsystem with Blueprint nodes and a C++ API. Uses Unreal's own HTTP and JSON modules; no third-party libraries.
Install
- Download rean-sdk-unreal-0.1.0.zip and unzip it into your project's
Plugins/folder (so you getPlugins/ReanSDK/ReanSDK.uplugin). - Regenerate project files and build. Unreal Engine 5.1 or newer.
- Open Project Settings › Plugins › REAN SDK and paste your client id.
[/Script/ReanSDK.ReanSettings]
ClientId=rean_xxxxxxxxxxxxxxxxxxxxxxxx
Scopes=openid profile offline_access friends.read presence.read presence.write invites
bSaveSession=TrueSign in
In Blueprints: Get Game Instance › Get Subsystem (Rean Subsystem), then call one of the sign-in nodes and bind the events.
#include "ReanSubsystem.h"
void AMyGameMode::BeginPlay()
{
Super::BeginPlay();
UReanSubsystem* Rean = GetGameInstance()->GetSubsystem<UReanSubsystem>();
FReanSignInDelegate OnDone;
OnDone.BindDynamic(this, &AMyGameMode::OnReanSignedIn);
if (Rean->WasStartedByLauncher())
{
Rean->SignInWithLauncher(OnDone);
}
else
{
Rean->RestoreSession(OnDone); // saved session from a previous launch
}
}
void AMyGameMode::OnReanSignedIn(bool bSuccess, const FReanUser& User, const FString& Error)
{
if (!bSuccess)
{
// No session yet: show a device code
FReanDeviceCodeDelegate OnCode;
OnCode.BindDynamic(this, &AMyGameMode::ShowReanCode);
FReanSignInDelegate OnDone;
OnDone.BindDynamic(this, &AMyGameMode::OnReanSignedIn);
GetGameInstance()->GetSubsystem<UReanSubsystem>()->SignInWithDevice(OnCode, OnDone);
return;
}
UE_LOG(LogTemp, Log, TEXT("Signed in as %s"), *User.DisplayName);
}Callbacks must be UFUNCTION()s. With bSaveSession on, the refresh token is kept in the ReanSession save slot; turn it off and use OnSessionChanged + GetRefreshToken() to store it in your platform's secure storage instead.
Friends, presence and invites
// Friends (with presence)
FReanFriendsDelegate OnFriends;
OnFriends.BindDynamic(this, &AMyHUD::OnFriends);
Rean->GetFriends(OnFriends);
// Rich presence: kept alive every 60 s until ClearActivity()
FReanActivity Activity;
Activity.Details = TEXT("Ranked");
Activity.State = TEXT("Round 1");
Activity.PartyId = LobbyId;
Activity.PartySize = 1;
Activity.PartyMax = 5;
Activity.bJoinable = true;
Activity.StartedAt = FDateTime::UtcNow().ToUnixTimestamp();
Rean->SetActivity(Activity);
// Invites
Rean->OnEvent.AddDynamic(this, &AMyHUD::OnReanEvent); // invite.received, invite.accepted, invite.declined
Rean->SendInvite(FriendId, LobbyId, TEXT("Join me!"), OnSent);
Rean->RespondToInvite(InviteId, true, OnJoin); // OnJoin gets the join secretAPI summary
| Function | Description |
|---|---|
SignInWithLauncher | Uses -ReanAuthCode from the command line. |
RestoreSession / SignInWithRefreshToken | Signs back in silently. |
SignInWithDevice | Code + reanstudios.com/activate. |
SignOut | Clears presence, revokes the session. |
GetFriends | Friends with presence. |
SetActivity / ClearActivity | Rich presence (auto heartbeat). |
GetInvites | Pending invites in your game. |
SendInvite / RespondToInvite | Invites between friends. |
OnEvent | Polled every EventPollSeconds (default 10). |
OnSessionChanged | Sign-in, sign-out, refresh-token rotation. |