feat(upserver): 接入认证与KV存档并完成限定钓鱼闭环
This commit is contained in:
@@ -13,6 +13,17 @@ namespace game
|
||||
|
||||
public class AggUserService : PlayFabUserService
|
||||
{
|
||||
public AggUserService() { }
|
||||
internal AggUserService(PlayerDataStorage.PlayerKVControlledLoadCapability capability) : base(capability) { }
|
||||
internal IReadOnlyList<PlayerDataStorage.PlayerKVIdentityChannel> KVLinkedAccounts { get; private set; } =
|
||||
Array.Empty<PlayerDataStorage.PlayerKVIdentityChannel>();
|
||||
internal override void ResetForKVLoad()
|
||||
{
|
||||
base.ResetForKVLoad();
|
||||
KVLinkedAccounts=Array.Empty<PlayerDataStorage.PlayerKVIdentityChannel>();
|
||||
}
|
||||
internal override void ReplaceKVLinked(PlayerDataStorage.PlayerKVLoginState state)
|
||||
{ KVLinkedAccounts=new List<PlayerDataStorage.PlayerKVIdentityChannel>(state.Linked).AsReadOnly(); }
|
||||
protected override string NewPlayerName
|
||||
{
|
||||
get
|
||||
@@ -45,6 +56,18 @@ namespace game
|
||||
|
||||
public override async Task<ELoginStep> Login(Action<int> progress, bool tryLoginByToken = true)
|
||||
{
|
||||
#if UNITY_EDITOR && !SERVICE_HOST
|
||||
if(game.PlayerDataStorage.PlayerKVGameplayLoop.Enabled)
|
||||
{
|
||||
CustomId=game.PlayerDataStorage.PlayerKVGameplayLoop.Permit.PlayerId;
|
||||
OnInitData+=InitData;
|
||||
try { return await LoginWithBackend(progress,"kv-loop"); }
|
||||
finally { OnInitData-=InitData; }
|
||||
}
|
||||
#endif
|
||||
var backend=CaptureSaveBackend();
|
||||
if(RejectSaveBackend(backend)) return ELoginStep.Api;
|
||||
var generation = logoutGeneration;
|
||||
if (IsLogin)
|
||||
{
|
||||
progress?.Invoke(3);
|
||||
@@ -58,10 +81,12 @@ namespace game
|
||||
if (!TYSdkFacade.IsLoggedIn)
|
||||
{
|
||||
loginInfo = await TYSdkFacade.Instance.LoginBySns();
|
||||
if (generation != logoutGeneration) return ELoginStep.Sdk;
|
||||
|
||||
if (!loginInfo.isSuccess && tryLoginByToken)
|
||||
{
|
||||
loginInfo = await TYSdkFacade.Instance.LoginByToken();
|
||||
if (generation != logoutGeneration) return ELoginStep.Sdk;
|
||||
}
|
||||
|
||||
if (!loginInfo.isSuccess)
|
||||
@@ -69,7 +94,9 @@ namespace game
|
||||
var evt = new LoginTypeEvt();
|
||||
GContext.Publish(evt);
|
||||
var loginType = await evt.loginType.Task;
|
||||
if (generation != logoutGeneration) return ELoginStep.Sdk;
|
||||
loginInfo = await TYSdkFacade.Instance.Login(loginType);
|
||||
if (generation != logoutGeneration) return ELoginStep.Sdk;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -80,21 +107,18 @@ namespace game
|
||||
|
||||
if (!loginInfo.isSuccess) return ELoginStep.Sdk;
|
||||
|
||||
progress.Invoke(1);
|
||||
progress?.Invoke(1);
|
||||
|
||||
CustomId = loginInfo.StrUserId;
|
||||
|
||||
|
||||
OnInitData += InitData;
|
||||
|
||||
var step = await base.Login(step => progress?.Invoke(step + 1));
|
||||
if (step != ELoginStep.Done)
|
||||
{
|
||||
OnInitData -= InitData;
|
||||
return step;
|
||||
}
|
||||
|
||||
OnInitData -= InitData;
|
||||
ELoginStep step;
|
||||
try { step = await LoginWithBackend(value => progress?.Invoke(value + 1),backend); }
|
||||
finally { OnInitData -= InitData; }
|
||||
if (generation != logoutGeneration) return ELoginStep.Sdk;
|
||||
if (step != ELoginStep.Done) return step;
|
||||
|
||||
if (ChannelManager.IsRustoreStore)
|
||||
{
|
||||
@@ -166,8 +190,9 @@ namespace game
|
||||
|
||||
public override void Logout()
|
||||
{
|
||||
TYSdkFacade.Instance.Logout();
|
||||
base.Logout();
|
||||
if(IsControlledKVInstance) return;
|
||||
TYSdkFacade.Instance.Logout();
|
||||
}
|
||||
|
||||
public override async Task<bool> GetLinkState(EAccoutType accoutType)
|
||||
@@ -193,8 +218,25 @@ namespace game
|
||||
return (linkResult.code, linkResult.userId);
|
||||
}
|
||||
|
||||
internal int KVNotificationCount { get; private set; }
|
||||
internal override async Task<PlayerDataStorage.PlayerKVGameLoadResult> LoadKVForValidationAsync(PlayerDataStorage.PlayerKVGameLoadCapability capability)
|
||||
{
|
||||
EnterKVReceiver(ReceiveKVData);
|
||||
try { return await base.LoadKVForValidationAsync(capability); }
|
||||
finally { ExitKVReceiver(); }
|
||||
}
|
||||
void ReceiveKVData(IDictionary<string,string> data)
|
||||
{
|
||||
if(!IsControlledKVInstance || KVLoadingCopy==null || data.Count!=KVLoadingCopy.Count)
|
||||
throw new InvalidOperationException("Controlled notification window invalid.");
|
||||
KVNotificationCount++;
|
||||
}
|
||||
private void InitData(IDictionary<string, string> data)
|
||||
{
|
||||
#if UNITY_EDITOR && !SERVICE_HOST
|
||||
// Editor loop has no channel SDK login. M31 already replaced account URLs and linked flags.
|
||||
if(PlayerDataStorage.PlayerKVGameplayLoop.Enabled) return;
|
||||
#endif
|
||||
if (data.TryGetValue(EAccoutType.hwGoogle.ToString(), out var google) && google == "1")
|
||||
{
|
||||
TYSdkFacade.TYAccountInfo.linkedAccout.Add(EAccoutType.hwGoogle);
|
||||
|
||||
Reference in New Issue
Block a user