Identity & Sessions

UCrimsonOnlineIdentityService

Wraps IOnlineIdentity. Manages platform login, logout, and presence status for all local players.

FunctionDescription
Login(LocalPlayerIndex, Delegate)Initiates platform login for the given local player
Logout(LocalPlayerIndex, Delegate)Logs out the given local player
GetLoginStatus(LocalPlayerIndex)Returns ECrimsonLoginStatus (NotLoggedIn / LoggingIn / LoggedIn)
GetPlayerInfo(LocalPlayerIndex)Returns FCrimsonOnlinePlayerInfo (UniqueId, DisplayName, AvatarURL)
GetUniquePlayerId(LocalPlayerIndex)Returns TSharedPtr<const FUniqueNetId>
IsLoggedIn(LocalPlayerIndex)Returns bool
OnLoginStatusChangedDelegate broadcast on any local player login state change
Async node
UCrimsonAsyncAction_Login — Blueprint async action. Pins: LocalPlayerIndex (int), On Success (LocalPlayerIndex, PlayerInfo), On Failure (LocalPlayerIndex, ErrorMessage).

UCrimsonOnlineSessionService

Wraps IOnlineSessions. Handles session creation, search, join, and destruction. Session settings are configured via FCrimsonSessionSettings.

FCrimsonSessionSettings

FieldTypeDescription
MaxPublicConnectionsint32Max simultaneous players (default 4)
bIsLANboolLAN session (disables online matchmaking)
bAllowJoinInProgressboolAllow join after session has started
bUsesPresenceboolPopulate presence with session info
bAllowInvitesboolAllow platform friend invites
bUsesStatsboolTrack stats for this session
bShouldAdvertiseboolAdvertise in matchmaking search
MapNameFNameMap to load on session start
CustomSettingsTMap<FName, FString>Arbitrary key-value pairs for search filters

Full API

FunctionDescription
CreateSession(LocalPlayerIndex, SessionName, Settings, Delegate)Creates and advertises a new session
FindSessions(LocalPlayerIndex, MaxResults, bIsLAN, Delegate)Searches for sessions matching optional custom filters
JoinSession(LocalPlayerIndex, SessionName, SearchResult, Delegate)Joins a session from a FCrimsonSessionSearchResult
DestroySession(SessionName, Delegate)Destroys the named session
StartSession(SessionName, Delegate)Transitions session from pending to in-progress
EndSession(SessionName, Delegate)Transitions session from in-progress to ended
UpdateSession(SessionName, Settings, Delegate)Updates settings of an existing session
GetResolvedConnectString(SessionName, PortType)Returns connection string for travel
GetSessionState(SessionName)Returns ECrimsonSessionState
GetSessionSettings(SessionName)Returns FCrimsonSessionSettings for the named session
RegisterPlayer(SessionName, PlayerId, bWasInvited, Delegate)Registers a player in the session
UnregisterPlayer(SessionName, PlayerId, Delegate)Unregisters a player from the session
OnSessionCreatedDelegate: session name + bool success
OnSessionStartedDelegate: session name + bool success
OnSessionEndedDelegate: session name + bool success
OnSessionDestroyedDelegate: session name + bool success
OnFindSessionsCompleteDelegate: TArray<FCrimsonSessionSearchResult> + bool success
OnJoinSessionCompleteDelegate: session name + ECrimsonSessionState

Host + client example

cpp
// HOST
FCrimsonSessionSettings Settings;
Settings.MaxPublicConnections = 4;
Settings.bShouldAdvertise = true;
Settings.MapName = "Level_Arena";
GetSessionService()->CreateSession(0, NAME_GameSession, Settings,
FCrimsonSessionCreatedDelegate::CreateLambda([this](FName, bool bOk)
{
if (bOk) GetSessionService()->StartSession(NAME_GameSession, {});
}));
// CLIENT
GetSessionService()->FindSessions(0, 10, false,
FCrimsonFindSessionsCompleteDelegate::CreateLambda(
[this](const TArray<FCrimsonSessionSearchResult>& Results, bool bOk)
{
if (bOk && Results.Num() > 0)
GetSessionService()->JoinSession(0, NAME_GameSession, Results[0], {});
}));