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

  1. Download rean-sdk-unreal-0.1.0.zip and unzip it into your project's Plugins/ folder (so you get Plugins/ReanSDK/ReanSDK.uplugin).
  2. Regenerate project files and build. Unreal Engine 5.1 or newer.
  3. Open Project Settings › Plugins › REAN SDK and paste your client id.
Config/DefaultGame.ini (written by the settings page)
[/Script/ReanSDK.ReanSettings]
ClientId=rean_xxxxxxxxxxxxxxxxxxxxxxxx
Scopes=openid profile offline_access friends.read presence.read presence.write invites
bSaveSession=True

Sign in

In Blueprints: Get Game Instance › Get Subsystem (Rean Subsystem), then call one of the sign-in nodes and bind the events.

C++
#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

cpp
// 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 secret

API summary

FunctionDescription
SignInWithLauncherUses -ReanAuthCode from the command line.
RestoreSession / SignInWithRefreshTokenSigns back in silently.
SignInWithDeviceCode + reanstudios.com/activate.
SignOutClears presence, revokes the session.
GetFriendsFriends with presence.
SetActivity / ClearActivityRich presence (auto heartbeat).
GetInvitesPending invites in your game.
SendInvite / RespondToInviteInvites between friends.
OnEventPolled every EventPollSeconds (default 10).
OnSessionChangedSign-in, sign-out, refresh-token rotation.