| 1 | namespace GodotTools.IdeMessaging |
| 2 | { |
| 3 | public class Message |
| 4 | { |
| 5 | public MessageKind Kind { get; } |
| 6 | public string Id { get; } |
| 7 | public MessageContent Content { get; } |
| 8 | |
| 9 | public Message(MessageKind kind, string id, MessageContent content) |
| 10 | { |
| 11 | Kind = kind; |
| 12 | Id = id; |
| 13 | Content = content; |
| 14 | } |
| 15 | |
| 16 | public override string ToString() |
| 17 | { |
| 18 | return $"{Kind} | {Id}"; |
| 19 | } |
| 20 | } |
| 21 | |
| 22 | public enum MessageKind |
| 23 | { |
| 24 | Request, |
| 25 | Response |
| 26 | } |
| 27 | |
| 28 | public enum MessageStatus |
| 29 | { |
| 30 | Ok, |
| 31 | RequestNotSupported, |
| 32 | InvalidRequestBody |
| 33 | } |
| 34 | |
| 35 | public readonly struct MessageContent |
| 36 | { |
| 37 | public MessageStatus Status { get; } |
| 38 | public string Body { get; } |
| 39 | |
| 40 | public MessageContent(string body) |
| 41 | { |
| 42 | Status = MessageStatus.Ok; |
| 43 | Body = body; |
| 44 | } |
| 45 | |
| 46 | public MessageContent(MessageStatus status, string body) |
| 47 | { |
| 48 | Status = status; |
| 49 | Body = body; |
| 50 | } |
| 51 | } |
| 52 | } |