1. Login with a Supported Authentication Service
❗ Note: Login is required before accessing most features.
❗ Note: The login flow provided by
Overlaywill be removed inNew Overlayimplementation which will be released soon. You need to handlePGOS Loginon your side inNew Overlay.
PGOS login is required before using any other Overlay functionalities, Overlay provides a capsulated layer to login PGOS by calling SessionService::StartSession.
FWeaverSessionAuthInfo SessionAuthInfo;
FWeaverSessionID SessionID;
SessionAuthInfo.OpenId = ret.OpenID;
SessionAuthInfo.Token = ret.Token;
// UserName and AvatarUrl are only used for new PGOS accounts since they are initially emtpy.
SessionAuthInfo.UserName = ret.UserName;
SessionAuthInfo.AvatarUrl = ret.PicUrl;
SessionAuthInfo.AccountChannelId = FString::FromInt(ret.ChannelID);
SessionAuthInfo.AccountProvider = EWeaverAccountProvider::INTL;
if (IPgosWeaverModule::Get().GetSessionService()->StartSession(SessionAuthInfo, SessionID) == EWeaverSessionOperationResult::Succeeded)
{
// When StartSession returns Succeeded, it means that the PGOS login request was successfully initiated, but it does not mean that the login is complete.
return;
}
1.1 Keyword Definition
AccountProvider: indicates which account service is used, all providers currently supported are:
| Provider | Description |
|---|---|
| FakeAccount | PGOS built-in Fake Account (only for the development stage) |
| INTL | INTL PlayerNetwork |
| WeGame | WeGame RailSDK |
OpenId: The user identity provided by the account-service provider.
Token: A valid ticket corresponding to the OpenId provided by the account service provider.
Since StartSession is just a wrapper of PGOSSDK Login call, check out PGOS Player Auth for more information on the meanings of each field.
2. Session Events
// register a callback to handle the session state change event
IPgosWeaverModule::Get().GetSessionService()->OnSessionStateChanged.AddUObject(this, &YourClass::OnSessionStateChanged);
void YourClass::OnSessionStateChanged(EWeaverSessionState SessionState)
{
if (SessionState == EWeaverSessionState::Connected)
{
// PGOS login succeded
}
}
If more details are needed, also use IPgosSDKCpp::Get().GetClientPlayerAuthAPI()->OnPlayerSessionChanged event.
❗ Note: see also PGOS Monitor Events
IPgosSDKCpp::Get().GetClientPlayerAuthAPI()->OnPlayerSessionChanged().AddLambda([](const FClientPlayerSessionChangedEvt& ChangedEvt)
{
UE_LOG(LogTemp, Log, TEXT("OnPlayerSessionChanged evt=%s msg=%s"), *UEnum::GetValueAsString(ChangedEvt.evt), *ChangedEvt.msg);
//
});
3. Built-in Login Helper Methods (Deprecated)
UPgosBlueprintLibrary::Login(), UPgosBlueprintLibrary::LoginEx() and LoginView widget are deprecated and only used internally, do not use them in practice.