feat(upserver): 接入认证与KV存档并完成限定钓鱼闭环
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using game.Account;
|
||||
|
||||
namespace game.PlayerDataStorage
|
||||
{
|
||||
public enum PlayerKVLoginPrepareError
|
||||
{
|
||||
None, Validation, Cancelled, Stale, AuthenticationFailed, OwnerRejected, NotReady, Unexpected, CloseFailed
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Historical outcome of one preparation, not permission to initialize gameplay or create a save.
|
||||
/// Check the context's IsCurrent before using a prepared snapshot. Failure/cancellation waits for
|
||||
/// actual transport and Close completion; a transport ignoring cancellation may hold it indefinitely.
|
||||
/// </summary>
|
||||
public sealed class PlayerKVLoginPrepareResult
|
||||
{
|
||||
public bool Prepared => Error == PlayerKVLoginPrepareError.None;
|
||||
public PlayerKVLoginPrepareError Error { get; }
|
||||
public PlayerKVLoginPrepareError OriginalError { get; }
|
||||
public bool CleanupFailed => Error == PlayerKVLoginPrepareError.CloseFailed;
|
||||
public AccountLoginError? AccountError { get; }
|
||||
public PlayerKVGameOpenError? OpenError { get; }
|
||||
public PlayerKVSessionOpenError? OwnerError { get; }
|
||||
public PlayerKVError? KVError { get; }
|
||||
public PlayerKVSyncStatus? SyncStatus { get; }
|
||||
public int? HttpStatusCode { get; }
|
||||
public string PlayerId { get; }
|
||||
public long Epoch { get; }
|
||||
public string OwnerInstanceId { get; }
|
||||
public string ExceptionType { get; }
|
||||
public string CleanupExceptionType { get; }
|
||||
public IReadOnlyDictionary<string, string> Data { get; }
|
||||
public bool IsEmpty => Prepared && Data.Count == 0;
|
||||
|
||||
internal PlayerKVLoginPrepareResult(PlayerKVLoginPrepareError error, string playerId, long epoch,
|
||||
AccountLoginError? accountError = null, int? httpStatus = null,
|
||||
PlayerKVGameOpenError? openError = null, PlayerKVSessionOpenError? ownerError = null,
|
||||
PlayerKVError? kvError = null, PlayerKVSyncStatus? syncStatus = null,
|
||||
string ownerId = null, IReadOnlyDictionary<string, string> data = null,
|
||||
string exceptionType = null, string cleanupExceptionType = null,
|
||||
PlayerKVLoginPrepareError? originalError = null)
|
||||
{
|
||||
Error = error; OriginalError = originalError ?? error; PlayerId = playerId; Epoch = epoch;
|
||||
AccountError = accountError; HttpStatusCode = httpStatus; OpenError = openError;
|
||||
OwnerError = ownerError; KVError = kvError; SyncStatus = syncStatus; OwnerInstanceId = ownerId;
|
||||
ExceptionType = exceptionType; CleanupExceptionType = cleanupExceptionType;
|
||||
if (!Prepared) return;
|
||||
if (data == null) throw new ArgumentNullException(nameof(data));
|
||||
var copy = new Dictionary<string, string>(StringComparer.Ordinal);
|
||||
foreach (var pair in data) copy.Add(pair.Key, pair.Value);
|
||||
Data = new ReadOnlyDictionary<string, string>(copy);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user