aboutsummaryrefslogtreecommitdiff
path: root/include/sibs/Message.hpp
blob: 45912216a0cc877d6633c4e716c275d950e1e6e8 (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
#pragma once

#include "../types.hpp"
#include <sibs/SafeSerializer.hpp>

namespace sibs
{
    enum class MessageType : u8
    {
        NONE,
        DATA,
        SUBSCRIBE,
        UNSUBSCRIBE
    };

    class Message
    {
    public:
        Message(MessageType messageType);

        void append(const void *data, const usize size);

        usize getDataSize() const { return serializer.getSize() - 1; }
        usize getRawSize() const { return serializer.getSize(); }

        const u8* data() { return serializer.getBuffer().data(); }

        sibs::SafeSerializer serializer;
    };
}