forked from empyreanx/gdnet
-
Notifications
You must be signed in to change notification settings - Fork 25
/
gdnet_message.h
58 lines (38 loc) · 1.01 KB
/
gdnet_message.h
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
53
54
55
56
57
58
/* gdnet_packet.h */
#ifndef GDNET_MESSAGE_H
#define GDNET_MESSAGE_H
#include <string.h>
#include "core/int_types.h"
#include "core/os/memory.h"
#include "core/object.h"
#include "core/variant.h"
class GDNetMessage : public Object {
GDCLASS(GDNetMessage,Object);
public:
enum Type {
UNSEQUENCED,
SEQUENCED,
RELIABLE
};
private:
Type _type;
bool _broadcast;
int _peer_id;
int _channel_id;
PoolByteArray _packet;
protected:
static void _bind_methods();
public:
GDNetMessage(Type type);
Type get_type() { return _type; }
int get_peer_id() { return _peer_id; }
void set_peer_id(int peer_id) { _peer_id = peer_id; }
int get_channel_id() { return _channel_id; }
void set_channel_id(int channel_id) { _channel_id = channel_id; }
void set_broadcast(bool broadcast) { _broadcast = broadcast; }
bool is_broadcast() { return _broadcast; }
PoolByteArray& get_packet() { return _packet; }
void set_packet(const PoolByteArray& packet) { _packet = packet; }
};
VARIANT_ENUM_CAST(GDNetMessage::Type);
#endif