BITKit/Packages/Runtime/Network/NetworkCore.cs

34 lines
908 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Cysharp.Threading.Tasks;
using System.Text;
using UnityEngine.Networking;
using System.Threading;
namespace BITKit
{
public class NetworkCore
{
static Dictionary<string, int> counter = new();
[RuntimeInitializeOnLoadMethod]
static void Reload()
{
counter.Clear();
}
[BITCommand]
public static async void NetworkStatus()
{
await UniTask.SwitchToMainThread();
StringBuilder stringBuilder = new();
foreach (var count in counter)
{
stringBuilder.Append($"URL:{count.Key}\tCount:{count.Value}");
}
Debug.Log(stringBuilder);
}
public static void Add(string url)
{
counter.Set(url, counter.Get(url) + 1);
}
}
}