2020-05-09 20:45:43 +02:00
|
|
|
using GodotTools.IdeMessaging.Requests;
|
|
|
|
using GodotTools.IdeMessaging.Utils;
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
|
|
|
namespace GodotTools.IdeMessaging
|
|
|
|
{
|
|
|
|
public abstract class ResponseAwaiter : NotifyAwaiter<Response>
|
|
|
|
{
|
|
|
|
public abstract void SetResult(MessageContent content);
|
|
|
|
}
|
|
|
|
|
|
|
|
public class ResponseAwaiter<T> : ResponseAwaiter
|
|
|
|
where T : Response, new()
|
|
|
|
{
|
|
|
|
public override void SetResult(MessageContent content)
|
|
|
|
{
|
|
|
|
if (content.Status == MessageStatus.Ok)
|
2024-01-13 05:24:12 +01:00
|
|
|
SetResult(JsonConvert.DeserializeObject<T>(content.Body)!);
|
2020-05-09 20:45:43 +02:00
|
|
|
else
|
2022-08-27 03:22:23 +02:00
|
|
|
SetResult(new T { Status = content.Status });
|
2020-05-09 20:45:43 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|