using System;
using System.Collections;
using System.Collections.Generic;
namespace YooAsset
{
internal class WebRequestCounter
{
///
/// 记录网络请求失败事件的次数
///
private static readonly Dictionary _requestFailedRecorder = new Dictionary(1000);
///
/// 记录请求失败事件
///
public static void RecordRequestFailed(string packageName, string eventName)
{
string key = $"{packageName}_{eventName}";
if (_requestFailedRecorder.ContainsKey(key) == false)
_requestFailedRecorder.Add(key, 0);
_requestFailedRecorder[key]++;
}
///
/// 获取请求失败的次数
///
public static int GetRequestFailedCount(string packageName, string eventName)
{
string key = $"{packageName}_{eventName}";
if (_requestFailedRecorder.ContainsKey(key) == false)
_requestFailedRecorder.Add(key, 0);
return _requestFailedRecorder[key];
}
}
}