NLDClient-yudde/ProjectNLD/Assets/Code/Scripts/Framework/BI/BIManager.cs

622 lines
19 KiB
C#
Raw Normal View History

2025-03-18 18:40:56 +08:00
using Cysharp.Threading.Tasks;
2025-03-18 19:13:40 +08:00
using Newtonsoft.Json;
2024-05-14 15:29:31 +08:00
using PhxhSDK;
2024-07-25 17:06:02 +08:00
using System;
2025-06-11 16:12:05 +08:00
using System.Collections.Generic;
using UnityEngine;
2024-05-14 15:29:31 +08:00
2025-04-22 15:39:26 +08:00
public partial class BIManager : Singlenton<BIManager>, IInitable, IUpdatable
2024-05-14 15:29:31 +08:00
{
2025-04-22 15:39:26 +08:00
/// <summary>
2025-05-13 15:27:38 +08:00
/// 基础属性
2025-04-22 15:39:26 +08:00
/// </summary>
2025-05-13 15:27:38 +08:00
private BIBaseInfo baseInfo;
2025-04-22 15:39:26 +08:00
/// <summary>
2025-05-13 15:27:38 +08:00
/// 关卡属性
2025-04-22 15:39:26 +08:00
/// </summary>
2025-05-13 15:27:38 +08:00
private BILevelInfo levelInfo;
2025-04-22 15:39:26 +08:00
/// <summary>
2025-05-13 15:27:38 +08:00
/// BI接口
2025-04-22 15:39:26 +08:00
/// </summary>
2025-05-13 15:27:38 +08:00
private IBIService _biService;
2025-04-22 15:39:26 +08:00
/// <summary>
2025-05-13 15:27:38 +08:00
/// 一次性事件缓存类
2025-04-22 15:39:26 +08:00
/// </summary>
2025-05-13 15:27:38 +08:00
private StorageEvent _storageEvent;
2025-04-22 15:39:26 +08:00
/// <summary>
2025-05-13 15:27:38 +08:00
/// 是否初始化
2025-04-22 15:39:26 +08:00
/// </summary>
2025-05-13 15:27:38 +08:00
private bool _isInit;
2025-04-22 15:39:26 +08:00
/// <summary>
2025-05-13 15:27:38 +08:00
/// 启用自己服务器打点
2025-04-22 15:39:26 +08:00
/// </summary>
2025-05-13 15:27:38 +08:00
private bool sendPhxh;
2025-04-22 15:39:26 +08:00
/// <summary>
2025-05-13 15:27:38 +08:00
/// 参数字典
2025-04-22 15:39:26 +08:00
/// </summary>
2025-05-13 15:27:38 +08:00
private Dictionary<string, object> _tempEventDictionary = new(12);
2025-04-22 15:39:26 +08:00
2025-06-11 16:12:05 +08:00
private readonly string PhxhBiUrl = "https://bi.kedrgame.com/api/v1/events";
/// <summary>
/// BI专属accessKey请勿与中台key混用
/// </summary>
private readonly string AccessKey = "yd9kWI798IWyyq1t";
/// <summary>
/// BI专属密钥请勿与中台密钥混用
/// </summary>
private readonly string SecretKey = "iQLHTbOqeXtZZpxOZve-PDxTK9DkHPSKRbpXb30eS3g=";
2025-05-13 15:27:38 +08:00
#region 初始化
2025-04-22 15:39:26 +08:00
/// <summary>
2025-05-13 15:27:38 +08:00
/// 游戏启动初始化
2025-04-22 15:39:26 +08:00
/// </summary>
2024-05-14 15:29:31 +08:00
public void Init()
{
2025-05-13 15:27:38 +08:00
baseInfo = new BIBaseInfo();
levelInfo = new BILevelInfo();
_storageEvent = StorageMgr.Instance.GetStorage<StorageEvent>(Framework.Constants.Storage.BI_FTE_EVENT);
_storageEvent ??= new StorageEvent();
InitDictPool();
_networkAvailable = true;
_useQueueMode = _sendInterval > 0;
InitService();
2024-05-14 15:29:31 +08:00
2025-03-20 14:20:08 +08:00
#if BI_PHXH
2025-04-22 15:39:26 +08:00
sendPhxh = true;
2025-05-13 15:27:38 +08:00
#else
sendPhxh = false;
2025-03-20 14:20:08 +08:00
#endif
2025-05-13 15:27:38 +08:00
_isInit = true;
2024-05-14 15:29:31 +08:00
}
2025-04-22 15:39:26 +08:00
/// <summary>
2025-05-13 15:27:38 +08:00
/// 登陆后初始化
2025-04-22 15:39:26 +08:00
/// </summary>
/// <param name="name"></param>
2025-05-13 15:27:38 +08:00
public void AfterLoginInitService(SDKManager.SdkName name)
2025-04-22 15:39:26 +08:00
{
_biService = SDKManager.Instance.GetSdkHelper(name) as IBIService;
if (_biService == null)
{
2025-05-13 15:27:38 +08:00
DebugUtil.Log("After Login Get BI Service error, SDK helper name is {0}", name);
2025-04-22 15:39:26 +08:00
}
2025-05-13 15:27:38 +08:00
}
2025-04-22 15:39:26 +08:00
2025-05-13 15:27:38 +08:00
/// <summary>
/// 初始化登陆后基本属性
/// </summary>
public void InitLoginBaseInfo()
{
baseInfo.SetUserInfo();
baseInfo.PrintAllValues();
2025-05-13 16:16:02 +08:00
if (!_isInit || _biService == null) return;
2025-05-13 15:27:38 +08:00
_biService.SetUser(baseInfo.actor_id);
SetUserProperty();
// 发送积累事件
2025-04-22 15:39:26 +08:00
SendQueuedEvents();
}
2025-05-13 15:27:38 +08:00
/// <summary>
/// 初始化第三方打点平台
/// </summary>
private void InitService()
2024-05-14 15:29:31 +08:00
{
2025-05-13 15:27:38 +08:00
var helperName = SDKManager.SdkName.TalkingData;
2025-04-22 15:39:26 +08:00
2024-05-31 14:26:33 +08:00
#if SDK_FIREBASE
helperName = SDKManager.SdkName.FireBase;
2024-05-14 15:29:31 +08:00
_biService = SDKManager.Instance.GetSdkHelper(helperName) as IBIService;
2024-05-31 14:26:33 +08:00
#endif
2024-07-22 17:08:02 +08:00
2024-05-31 14:26:33 +08:00
#if SDK_TAPTAP
helperName = SDKManager.SdkName.TapTap;
2025-04-22 15:39:26 +08:00
_biService = SDKManager.Instance.GetSdkHelper(helperName) as IBIService;
2024-05-31 14:26:33 +08:00
#endif
2024-07-22 17:08:02 +08:00
#if SDK_TALKINGDATA
2025-05-13 15:27:38 +08:00
// TD在登录后初始化
// helperName = SDKManager.SdkName.TalkingData;
// _biService = SDKManager.Instance.GetSdkHelper(helperName) as IBIService;
2025-04-22 15:39:26 +08:00
#endif
2024-05-14 15:29:31 +08:00
if (_biService == null)
{
2025-05-13 15:27:38 +08:00
DebugUtil.Log("Before Login Get BI Service error, SDK helper name is {0}", helperName);
2024-05-31 14:26:33 +08:00
}
2024-05-14 15:29:31 +08:00
}
2024-07-22 17:08:02 +08:00
2025-04-22 15:39:26 +08:00
/// <summary>
2025-05-13 15:27:38 +08:00
/// 设置用户属性
2025-04-22 15:39:26 +08:00
/// </summary>
2025-05-13 15:27:38 +08:00
private void SetUserProperty()
2024-07-22 17:08:02 +08:00
{
2025-06-11 16:12:05 +08:00
SetUserProperty("game_id", baseInfo.app_name);
2025-05-13 15:27:38 +08:00
SetUserProperty("channel", baseInfo.channel);
SetUserProperty("model", baseInfo.model);
SetUserProperty("uuid", baseInfo.uuid);
SetUserProperty("resolution", baseInfo.resolution);
SetUserProperty("platform", baseInfo.platform);
2025-05-14 15:11:09 +08:00
SetUserProperty("os", baseInfo.os);
2025-05-13 15:27:38 +08:00
SetUserProperty("version", baseInfo.version);
SetUserProperty("build_code", baseInfo.build_code);
SetUserProperty("assets_version", baseInfo.assets_version);
SetUserProperty("language", baseInfo.language);
// SetUserProperty("actor_id", baseInfo.actor_id); 通用接口
SetUserProperty("third_platform", baseInfo.third_platform);
SetUserProperty("third_id", baseInfo.third_id);
2025-04-22 15:39:26 +08:00
2025-05-13 15:27:38 +08:00
#if SDK_TALKINGDATA
// _biService?.SetUserProperty(TalkingDataProfileParamName.Param1, baseInfo.model);
// _biService?.SetUserProperty(TalkingDataProfileParamName.Param2, baseInfo.storage_info + "MB");
SetUserProperty("storage_info", baseInfo.storage_info + "MB");
#endif
2024-07-22 17:08:02 +08:00
}
2024-05-14 15:29:31 +08:00
2025-05-13 15:27:38 +08:00
public void SetUserProperty(string name, string value)
2025-02-11 14:40:04 +08:00
{
2025-05-13 15:27:38 +08:00
_biService?.SetUserProperty(name, value);
2025-02-11 14:40:04 +08:00
}
2025-04-22 15:39:26 +08:00
#endregion
#region 释放
public void Release()
2024-05-14 15:29:31 +08:00
{
2025-04-22 15:39:26 +08:00
_tempEventDictionary = null;
2025-05-13 15:27:38 +08:00
_dictPool = null; // 释放对象池
2025-04-22 15:39:26 +08:00
if (_isInit && _networkAvailable && eventQueue.Count > 0 && _biService != null)
2024-05-14 15:29:31 +08:00
{
2025-04-22 15:39:26 +08:00
SendQueuedEvents();
}
}
2024-05-14 15:29:31 +08:00
2025-04-22 15:39:26 +08:00
#endregion
2024-05-14 15:29:31 +08:00
2025-05-13 15:27:38 +08:00
#region 周期/队列 发送
/// <summary>
/// 事件队列
/// </summary>
private readonly Queue<(string, Dictionary<string, object>)> eventQueue = new();
/// <summary>
/// 是否使用队列模式(无网络或设置了发送周期)
/// </summary>
private bool _useQueueMode;
/// <summary>
/// 发送周期 默认随打随发
/// </summary>
private float _sendInterval = 0f;
/// <summary>
/// 网络状态 通过心跳包检测
/// </summary>
private bool _networkAvailable;
/// <summary>
/// 计时器
/// </summary>
private float _timer = 0f;
2024-05-14 15:29:31 +08:00
2025-04-22 15:39:26 +08:00
public void Update(float deltaTime)
{
if (!_isInit)
return;
2025-05-13 15:27:38 +08:00
// 检查网络状态
CheckNetworkStatus();
if (eventQueue.Count <= 0 || !_networkAvailable) return;
// 周期发送
if (_sendInterval > 0)
2025-04-22 15:39:26 +08:00
{
2025-05-13 15:27:38 +08:00
_timer += Time.deltaTime;
// 达到发送周期
if (_timer >= _sendInterval)
2024-09-18 14:51:32 +08:00
{
2025-05-13 15:27:38 +08:00
_timer = 0;
2025-04-22 15:39:26 +08:00
SendQueuedEvents();
2024-09-18 14:51:32 +08:00
}
2024-05-14 15:29:31 +08:00
}
2025-05-13 15:27:38 +08:00
else
2024-05-14 15:29:31 +08:00
{
2025-04-22 15:39:26 +08:00
SendQueuedEvents();
2024-05-14 15:29:31 +08:00
}
}
2025-04-22 15:39:26 +08:00
/// <summary>
2025-05-13 15:27:38 +08:00
/// 检查网络状态
2025-04-22 15:39:26 +08:00
/// </summary>
2025-05-13 15:27:38 +08:00
private void CheckNetworkStatus()
{
2025-05-13 15:27:38 +08:00
// 获取当前网络状态
var currentNetworkStatus = NetworkManager.Instance.NetworkAvailable;
// 如果网络状态发生变化
if (_networkAvailable == currentNetworkStatus) return;
if (currentNetworkStatus)
{
// 网络恢复
_networkAvailable = true;
_useQueueMode = _sendInterval > 0; // 如果有设置发送周期,仍然使用队列模式
// 如果没有设置发送周期,立即发送所有队列中的事件
if (!_useQueueMode && eventQueue.Count > 0)
{
SendQueuedEvents();
}
}
else
{
_networkAvailable = false;
_useQueueMode = true;
}
2025-04-22 15:39:26 +08:00
}
2025-04-22 15:39:26 +08:00
/// <summary>
/// 设置事件发送周期
/// </summary>
/// <param name="interval">发送周期单位秒设为0则立即发送</param>
public void SetSendInterval(float interval)
{
_sendInterval = Mathf.Max(0, interval);
_useQueueMode = !_networkAvailable || _sendInterval > 0;
}
2025-04-22 15:39:26 +08:00
#endregion
2025-04-22 15:39:26 +08:00
#region 发送事件
2025-05-13 15:27:38 +08:00
/// <summary>
/// 添加事件到队列
/// </summary>
private void EnqueueEvent(string eventName, Dictionary<string, object> param)
{
// 检查队列是否已满
if (eventQueue.Count >= MAX_QUEUE_SIZE)
{
DebugUtil.LogWarning("BI事件队列已满");
return;
}
// 从对象池获取字典并复制数据
var poolDict = GetDictFromPool();
if (param != null)
{
foreach (var item in param)
{
poolDict[item.Key] = item.Value;
}
}
2025-05-14 15:11:09 +08:00
2025-05-13 15:27:38 +08:00
eventQueue.Enqueue((eventName, poolDict));
}
2025-04-22 15:39:26 +08:00
/// <summary>
/// 发送队列中的所有事件
/// </summary>
private void SendQueuedEvents()
{
if (_biService == null || !_networkAvailable)
return;
2025-05-13 15:27:38 +08:00
// 只要队列有事件就全部处理
2025-04-22 15:39:26 +08:00
while (eventQueue.Count > 0)
{
2025-04-22 15:39:26 +08:00
//将缓存的事件上报
var (eventName, param) = eventQueue.Dequeue();
2025-05-13 17:47:02 +08:00
DebugUtil.Log("发送缓存事件: {0}, 事件参数: {1}", eventName, JsonConvert.SerializeObject(param));
2025-04-22 15:39:26 +08:00
_biService.ReportEvent(eventName, param);
TrackEventPhxh(eventName, param);
}
}
2024-05-14 15:29:31 +08:00
private bool IsRecorded(string eventName)
{
2024-10-18 13:47:19 +08:00
return _storageEvent.EventList.Contains(eventName);
2024-05-14 15:29:31 +08:00
}
2025-05-13 15:27:38 +08:00
/// <summary>
/// 更新关卡信息
/// </summary>
public void SetLevelInfo(int levelID, int levelType, int levelDifficulty, int levelEvent, int param0 = 0,
int param1 = 0)
{
if (!_isInit)
return;
levelInfo.level_id = levelID;
levelInfo.level_type = levelType;
levelInfo.difficulty = levelDifficulty;
levelInfo.level_event = levelEvent;
levelInfo.param0 = param0;
levelInfo.param1 = param1;
}
/// <summary>
/// 上报自定义事件
/// </summary>
public void TrackEvent(string eventName,
2025-05-13 17:47:02 +08:00
string param1Key = null, object param1 = null,
string param2Key = null, object param2 = null,
string param3Key = null, object param3 = null,
string param4Key = null, object param4 = null)
2025-05-13 15:27:38 +08:00
{
if (!_isInit)
return;
try
{
_tempEventDictionary.Clear();
var userParam = _tempEventDictionary;
2025-05-13 17:47:02 +08:00
if (!string.IsNullOrEmpty(param1Key) && param1 != null)
2025-05-13 15:27:38 +08:00
userParam.Add(param1Key, param1);
2025-05-13 17:47:02 +08:00
if (!string.IsNullOrEmpty(param2Key) && param2 != null)
2025-05-13 15:27:38 +08:00
userParam.Add(param2Key, param2);
2025-05-13 17:47:02 +08:00
if (!string.IsNullOrEmpty(param3Key) && param3 != null)
2025-05-13 15:27:38 +08:00
userParam.Add(param3Key, param3);
2025-05-13 17:47:02 +08:00
if (!string.IsNullOrEmpty(param4Key) && param4 != null)
userParam.Add(param4Key, param4);
2025-05-13 15:27:38 +08:00
if (_useQueueMode || _biService == null)
{
EnqueueEvent(eventName, userParam);
}
else
{
2025-05-13 17:47:02 +08:00
DebugUtil.Log("发送事件: {0}, 事件参数: {1}", eventName, JsonConvert.SerializeObject(userParam));
2025-05-13 15:27:38 +08:00
_biService.ReportEvent(eventName, userParam);
TrackEventPhxh(eventName, userParam);
}
}
catch (Exception e)
{
DebugUtil.LogError("Track event fail! EventName:" + eventName + ",\n error msg: " + e.Message);
}
}
/// <summary>
/// 上报一次性自定义事件
/// </summary>
public void TrackEventOnce(string eventName,
2025-05-13 17:47:02 +08:00
string param1Key = null, object param1 = null,
string param2Key = null, object param2 = null,
string param3Key = null, object param3 = null)
2025-05-13 15:27:38 +08:00
{
if (IsRecorded(eventName))
{
DebugUtil.Log("已经上报过 {0} 关卡事件,不会再次上报", eventName);
return;
}
TrackEvent(eventName, param1Key, param1, param2Key, param2, param3Key, param3);
}
/// <summary>
/// 上报关卡自定义事件 上报前需要更新关卡信息
/// </summary>
public void TrackLevelEvent(string eventName,
2025-05-13 17:47:02 +08:00
string param1Key = null, object param1 = null,
string param2Key = null, object param2 = null,
string param3Key = null, object param3 = null)
2025-05-13 15:27:38 +08:00
{
if (!_isInit)
return;
try
{
_tempEventDictionary.Clear();
var userParam = _tempEventDictionary;
userParam.Add("level_id", levelInfo.level_id); // 关卡ID
userParam.Add("level_type", levelInfo.level_type); // 关卡类型
userParam.Add("level_difficult", levelInfo.difficulty); // 关卡难度
userParam.Add("level_event", levelInfo.level_event); // 关卡进度
userParam.Add("level_param0", levelInfo.param0); // 关卡参数
userParam.Add("level_param1", levelInfo.param1);
2025-05-13 17:47:02 +08:00
if (!string.IsNullOrEmpty(param1Key) && param1 != null)
2025-05-13 15:27:38 +08:00
userParam.Add(param1Key, param1);
2025-05-13 17:47:02 +08:00
if (!string.IsNullOrEmpty(param2Key) && param2 != null)
2025-05-13 15:27:38 +08:00
userParam.Add(param2Key, param2);
2025-05-13 17:47:02 +08:00
if (!string.IsNullOrEmpty(param3Key) && param3 != null)
2025-05-13 15:27:38 +08:00
userParam.Add(param3Key, param3);
2025-05-13 17:47:02 +08:00
DebugUtil.Log("发送关卡事件: {0}, 事件参数: {1}", eventName, JsonConvert.SerializeObject(userParam));
2025-05-13 15:27:38 +08:00
if (_useQueueMode || _biService == null)
{
EnqueueEvent(eventName, userParam);
}
else
{
_biService.ReportEvent(eventName, userParam);
TrackEventPhxh(eventName, userParam);
}
}
catch (Exception e)
{
DebugUtil.LogError("Track event fail! EventName:" + eventName + ",\n error msg: " + e.Message);
}
}
/// <summary>
/// 上报一次性关卡自定义事件 上报前需要更新关卡信息
/// </summary>
public void TrackLevelEventOnce(string eventName,
2025-05-13 17:47:02 +08:00
string param1Key = null, object param1 = null,
string param2Key = null, object param2 = null,
string param3Key = null, object param3 = null)
2025-05-13 15:27:38 +08:00
{
if (IsRecorded(eventName))
{
DebugUtil.Log("已经上报过 {0} 关卡事件,不会再次上报", eventName);
return;
}
TrackLevelEvent(eventName, param1Key, param1, param2Key, param2, param3Key, param3);
}
#endregion
2025-04-22 15:39:26 +08:00
#region PHXH 服务器打点
2025-03-18 18:40:56 +08:00
private void TrackEventPhxh(string eventName, Dictionary<string, object> param)
{
2025-04-22 15:39:26 +08:00
if (!_isInit || !sendPhxh)
2025-03-18 18:40:56 +08:00
return;
try
{
2025-06-11 16:12:05 +08:00
var url = PhxhBiUrl;//PackDataInst.Inst.localInfo.httpUrl + "bi/events"; //"http://bi.kedrgame.com/api/v1/events"; //192.168.2.135:17777
2025-05-13 15:27:38 +08:00
baseInfo ??= new BIBaseInfo();
2025-05-14 15:11:09 +08:00
var timestampMs = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
2025-03-18 18:40:56 +08:00
var sendData = new PhxhBIEvent();
2025-03-20 12:17:42 +08:00
if (param != null)
2025-05-13 15:27:38 +08:00
{
var data = JsonConvert.SerializeObject(param);
2025-03-20 12:17:42 +08:00
sendData.event_value = data;
2025-05-13 15:27:38 +08:00
}
2025-05-14 15:11:09 +08:00
sendData.event_key = eventName;
2025-06-11 16:12:05 +08:00
sendData.app_name = baseInfo.app_name;
2025-05-13 15:27:38 +08:00
sendData.channel = baseInfo.channel;
sendData.model = baseInfo.model;
2025-06-25 17:48:43 +08:00
sendData.uuid = baseInfo.uuid;
2025-05-13 15:27:38 +08:00
sendData.resolution = baseInfo.resolution;
sendData.platform = baseInfo.platform;
2025-05-14 15:11:09 +08:00
sendData.os = baseInfo.os;
2025-05-13 15:27:38 +08:00
sendData.version = baseInfo.version;
sendData.build_code = baseInfo.build_code;
sendData.assets_version = baseInfo.assets_version;
sendData.language = baseInfo.language;
sendData.local_time = timestampMs;
sendData.actor_id = baseInfo.actor_id;
sendData.third_platform = baseInfo.third_platform;
sendData.third_id = baseInfo.third_id;
2025-06-11 16:12:05 +08:00
sendData.access_key = baseInfo.access_key;
2025-03-19 14:05:27 +08:00
2025-03-27 14:40:48 +08:00
Dictionary<string, string> headData = PostHeader.PostHeaderInfo(new Dictionary<string, string>
2025-03-19 14:05:27 +08:00
{
2025-05-14 15:11:09 +08:00
{ "event_key", sendData.event_key },
2025-06-11 16:12:05 +08:00
{ "app_name",sendData.app_name },
2025-04-22 15:39:26 +08:00
{ "event_value", sendData.event_value },
2025-05-13 15:27:38 +08:00
{ "channel", sendData.channel },
{ "model", sendData.model },
{ "uuid", sendData.uuid },
{ "resolution", sendData.resolution },
{ "platform", sendData.platform },
2025-05-14 15:11:09 +08:00
{ "os", sendData.os },
2025-05-13 15:27:38 +08:00
{ "version", sendData.version },
{ "build_code", sendData.build_code },
{ "assets_version", sendData.assets_version },
{ "language", sendData.language },
{ "actor_id", sendData.actor_id },
{ "third_platform", sendData.third_platform },
{ "third_id", sendData.third_id },
2025-05-14 15:11:09 +08:00
{ "local_time", sendData.local_time.ToString() },
2025-06-11 16:12:05 +08:00
{ "access_key", sendData.access_key }
}, SecretKey, AccessKey);
2025-03-18 18:40:56 +08:00
HttpHelper.PostAsync(url, sendData, headData).Forget();
}
catch (Exception e)
{
DebugUtil.LogError("Track event fail! EventName:" + eventName + ",\n error msg: " + e.Message);
}
}
2025-04-22 15:39:26 +08:00
private class PhxhBIEvent
2025-03-18 18:40:56 +08:00
{
2025-05-14 15:11:09 +08:00
public string event_key; // 事件名称
2025-05-13 15:27:38 +08:00
public string event_value; // 事件参数
// public string game_id; // 游戏ID 服务器自己打
2025-06-11 16:12:05 +08:00
public string app_name; // 游戏名称
2025-04-22 15:39:26 +08:00
public string channel; // 渠道
2025-05-13 15:27:38 +08:00
public string model; // 设备信息
public string uuid; // 设备ID
public string resolution; // 分辨率
2025-05-14 15:11:09 +08:00
public string platform; // 操作系统 安卓 ios
public string os; // 操作系统
2025-05-13 15:27:38 +08:00
public string version; // 游戏版本
public string build_code; // 构建版本
public string assets_version; // 资源版本
public string language; // 语言
public string actor_id; // 玩家ID
public string third_platform; // 第三方账号源
public string third_id; // 第三方账号ID
2025-06-11 16:12:05 +08:00
public string access_key;//中台accesskey包体打包内自带
2025-05-14 15:11:09 +08:00
public long local_time; // 本地时间
2025-05-13 15:27:38 +08:00
// public string server_time; // 服务器时间 服务器自己打
}
#endregion
#region 对象池
/// <summary>
/// 字典对象池大小
/// </summary>
private const int DICT_POOL_SIZE = 32;
/// <summary>
/// 对象池
/// </summary>
private List<Dictionary<string, object>> _dictPool;
/// <summary>
/// 对象池索引
/// </summary>
private int _dictPoolIndex = 0;
/// <summary>
/// 事件队列最大容量
/// </summary>
private const int MAX_QUEUE_SIZE = 1000;
/// <summary>
/// 初始化字典对象池
/// </summary>
private void InitDictPool()
{
_dictPool = new List<Dictionary<string, object>>(DICT_POOL_SIZE);
for (var i = 0; i < DICT_POOL_SIZE; i++)
{
_dictPool.Add(new Dictionary<string, object>(16));
}
}
/// <summary>
/// 从对象池获取一个字典
/// </summary>
private Dictionary<string, object> GetDictFromPool()
{
if (_dictPool == null || _dictPool.Count == 0)
{
InitDictPool();
}
var dict = _dictPool[_dictPoolIndex];
dict.Clear();
_dictPoolIndex = (_dictPoolIndex + 1) % DICT_POOL_SIZE;
return dict;
2025-03-18 18:40:56 +08:00
}
2025-04-22 15:39:26 +08:00
#endregion
2025-05-13 17:47:02 +08:00
2024-05-14 15:29:31 +08:00
}