Dragonfly 4.21
A text-based game engine
EventNetwork.h
1//
2// A "network data" event, generated when a network packet arrives.
3//
4
5#ifndef NO_NETWORK
6
7#ifndef __EVENT_NETWORK_H__
8#define __EVENT_NETWORK_H__
9
10// System includes.
11#include <string>
12
13// Engine includes.
14#include "Event.h"
15
16namespace df {
17
18const std::string NETWORK_EVENT = "df-network";
19
20enum class NetworkEventLabel {
21 UNDEFINED = -1,
22 ACCEPT,
23 CONNECT,
24 CLOSE,
25 DATA,
26};
27
28class EventNetwork : public Event {
29
30 private:
31 EventNetwork(); // Must provide type in constructor.
32 NetworkEventLabel m_label; // Label, depending upon type.
33 int m_sock; // Socket of connection.
34 int m_bytes; // Total number of bytes in message.
35 void *m_p_buff; // Message bytes.
36
37 public:
38 // Constructor must provide label.
39 EventNetwork(NetworkEventLabel label);
40
41 // Set label.
42 void setLabel(NetworkEventLabel new_label);
43
44 // Get label.
45 NetworkEventLabel getLabel() const;
46
47 // Set socket.
48 void setSocket(int new_sock);
49
50 // Get socket.
51 int getSocket() const;
52
53 // Set number of bytes in message.
54 void setBytes(int new_bytes);
55
56 // Get number of bytes in message.
57 int getBytes() const;
58
59 // Set message.
60 void setMessage(void *p_new_buff);
61
62 // Get message.
63 void *getMessage() const;
64};
65
66} // end of namespace df
67
68#endif // __EVENT_NETWORK_H__
69
70#endif // NO_NETWORK
Definition: EventNetwork.h:28
Definition: Event.h:15
An animation for a sprite.
Definition: Animation.h:15