Dragonfly  4.4
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 
10 namespace df {
11 
12 const std::string NETWORK_EVENT = "df::network";
13 
14 namespace Network {
15 enum Label {
16  UNDEFINED_LABEL = -1,
17  ACCEPT,
18  CONNECT,
19  CLOSE,
20  DATA,
21 };
22 } // namespace Network
23 
24 class 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; // Number of bytes avail (0 if connection).
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 available.
49  void setBytes(int new_bytes);
50 
51  // Get number of bytes available.
52  int getBytes() const;
53 };
54 
55 } // end of namespace df
56 
57 #endif // __EVENT_NETWORK_H__
Definition: Event.h:15
A 2-d bounding box.
Definition: Box.h:10
Definition: EventNetwork.h:24