52 lines
1.6 KiB
C#
52 lines
1.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using BestHTTP;
|
|
using Cysharp.Threading.Tasks;
|
|
using EasyInject.Attributes;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
namespace GameLogic.Origin.data
|
|
{
|
|
[Component]
|
|
public class AgvTaskListData
|
|
{
|
|
[Autowired] private NetWorkComponent _netWork;
|
|
public static List<AgvTaskInfo> AgvTaskList = new ();
|
|
|
|
public void Init()
|
|
{
|
|
UniTask.RunOnThreadPool(delegate
|
|
{
|
|
_netWork.RemoteGetAgvTaskListData((HTTPRequest originalRequest, HTTPResponse response) =>
|
|
{
|
|
try
|
|
{
|
|
if (response == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (response.IsSuccess)
|
|
{
|
|
JObject resultData = JObject.Parse(response.DataAsText);
|
|
string json = resultData["object"].ToString();
|
|
if (!string.IsNullOrEmpty(json))
|
|
{
|
|
List<AgvTaskInfo> agvTasks = JsonConvert.DeserializeObject<List<AgvTaskInfo>>(json);
|
|
AgvTaskList = agvTasks;
|
|
originalRequest.Send();
|
|
}
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Console.WriteLine(e);
|
|
throw;
|
|
}
|
|
|
|
});
|
|
}, false);
|
|
}
|
|
}
|
|
} |