feat(upserver): 保存M2客户端KV迁移至本人统计写检查点
保存独立KV用户服务、固定会话存档与原业务接线,以及C3d资料缓存和C3e本人统计写。 保留原PF/AGG路线、业务公式和时序;榜单读取、好友资料、公告、匹配及首场景闸仍待完成。 验证:ServiceHost两条件各33组646断言;Unity CLI Loop编译0错误269警告。 包含相关方案、评审裁决、测试及状态文档。未操作服务器、正式账号或打包。
This commit is contained in:
@@ -2,9 +2,11 @@ using asap.core;
|
||||
using asap.playfab.async;
|
||||
using cfg;
|
||||
using game;
|
||||
using game.PlayerDataStorage;
|
||||
using PlayFab.ClientModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using tysdk;
|
||||
@@ -162,6 +164,27 @@ namespace GameCore
|
||||
{
|
||||
Statistics.Add(new StatisticUpdate() { StatisticName = names[i], Value = value[i] });
|
||||
}
|
||||
if (userService is KVUserService kvUser)
|
||||
{
|
||||
var store = kvUser.SaveStore;
|
||||
var writtenNames = new HashSet<string>(StringComparer.Ordinal);
|
||||
bool accepted = false;
|
||||
foreach (var statistic in Statistics)
|
||||
{
|
||||
if (!writtenNames.Add(statistic.StatisticName)) continue;
|
||||
var write = store.Write(statistic.StatisticName, statistic.Value.ToString(CultureInfo.InvariantCulture));
|
||||
if (write.Accepted) accepted = true;
|
||||
else Debug.LogError("KV statistic write failed: " + statistic.StatisticName + ": " + write.Error);
|
||||
}
|
||||
if (accepted)
|
||||
{
|
||||
var confirmation = await store.FlushAsync();
|
||||
if (confirmation.Status != PlayerSaveStatus.Confirmed)
|
||||
Debug.LogError("KV statistic save not confirmed: " + string.Join(",", writtenNames) +
|
||||
": " + confirmation.Status + ": " + confirmation.Error);
|
||||
}
|
||||
return;
|
||||
}
|
||||
UpdatePlayerStatisticsRequest request = new UpdatePlayerStatisticsRequest()
|
||||
{
|
||||
Statistics = Statistics,
|
||||
|
||||
Reference in New Issue
Block a user