summaryrefslogtreecommitdiff
path: root/modules/mono/editor/GodotTools/GodotTools.IdeMessaging/Message.cs
blob: 6903ec197b065b276bfccefb50b4fb52521b1875 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
namespace GodotTools.IdeMessaging
{
    public class Message
    {
        public MessageKind Kind { get; }
        public string Id { get; }
        public MessageContent Content { get; }

        public Message(MessageKind kind, string id, MessageContent content)
        {
            Kind = kind;
            Id = id;
            Content = content;
        }

        public override string ToString()
        {
            return $"{Kind} | {Id}";
        }
    }

    public enum MessageKind
    {
        Request,
        Response
    }

    public enum MessageStatus
    {
        Ok,
        RequestNotSupported,
        InvalidRequestBody
    }

    public readonly struct MessageContent
    {
        public MessageStatus Status { get; }
        public string Body { get; }

        public MessageContent(string body)
        {
            Status = MessageStatus.Ok;
            Body = body;
        }

        public MessageContent(MessageStatus status, string body)
        {
            Status = status;
            Body = body;
        }
    }
}