Dragonfly 4.20
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#include "Event.h"
11
12namespace df {
13
14const std::string NETWORK_EVENT = "df-network";
15
16enum class NetworkEventLabel {
17 UNDEFINED = -1,
18 ACCEPT,
19 CONNECT,
20 CLOSE,
21 DATA,
22};
23
24class EventNetwork : public Event {
25
26 private:
27 EventNetwork(); // Must provide type in constructor.
28 NetworkEventLabel m_label; // Label, depending upon type.
29 int m_socket_index; // Socket index of connection.
30 int m_bytes; // Total number of bytes in message (0 if conn).
31
32 public:
33 // Constructor must provide label.
34 EventNetwork(NetworkEventLabel label);
35
36 // Set label.
37 void setLabel(NetworkEventLabel new_label);
38
39 // Get label.
40 NetworkEventLabel getLabel() const;
41
42 // Set socket index.
43 void setSocketIndex(int new_socket_index);
44
45 // Get socket index.
46 int getSocketIndex() const;
47
48 // Set number of bytes in message.
49 void setBytes(int new_bytes);
50
51 // Get number of bytes in message.
52 int getBytes() const;
53};
54
55} // end of namespace df
56
57#endif // __EVENT_NETWORK_H__
58
59#endif // NO_NETWORK
Definition: EventNetwork.h:24
Definition: Event.h:15
An animation for a sprite.
Definition: Animation.h:15