mirror of
https://github.com/godotengine/godot.git
synced 2025-12-08 06:09:55 +00:00
C#: Rewrite GodotTools messaging protocol
This commit is contained in:
parent
f3bcd5f8dd
commit
3ce09246d1
42 changed files with 2245 additions and 1053 deletions
|
|
@ -0,0 +1,23 @@
|
|||
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)
|
||||
SetResult(JsonConvert.DeserializeObject<T>(content.Body));
|
||||
else
|
||||
SetResult(new T {Status = content.Status});
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue