using GodotTools.IdeMessaging.Requests; using GodotTools.IdeMessaging.Utils; using Newtonsoft.Json; namespace GodotTools.IdeMessaging { public abstract class ResponseAwaiter : NotifyAwaiter { public abstract void SetResult(MessageContent content); } public class ResponseAwaiter : ResponseAwaiter where T : Response, new() { public override void SetResult(MessageContent content) { if (content.Status == MessageStatus.Ok) SetResult(JsonConvert.DeserializeObject(content.Body)); else SetResult(new T { Status = content.Status }); } } }