Dragonfly 4.19
A text-based game engine
EventNetwork.h
1//
2// A "network data" event, generated when a network packet arrives.
3//
4
5#ifndef __EVENT_NETWORK_H__
6#define __EVENT_NETWORK_H__
7
8#include "Event.h"
9
10namespace df {
11
12const std::string NETWORK_EVENT = "df-network";
13
14namespace Network {
15enum Label {
16 UNDEFINED_LABEL = -1,
17 ACCEPT,
18 CONNECT,
19 CLOSE,
20 DATA,
21};
22} // namespace Network
23
24class EventNetwork : public Event {
25
26 private:
27 EventNetwork(); // Must provide type in constructor.
28 Network::Label 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(Network::Label label);
35
36 // Set label.
37 void setLabel(Network::Label new_label);
38
39 // Get label.
40 Network::Label 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__
Definition: EventNetwork.h:24
Definition: Event.h:15
An animation for a sprite.
Definition: Animation.h:15