SEGS  0.4.2
Super Entity Game Server
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
InternalEvents.h
Go to the documentation of this file.
1 /*
2  * SEGS - Super Entity Game Server
3  * http://www.segs.io/
4  * Copyright (c) 2006 - 2018 SEGS Team (see Authors.txt)
5  * This software is licensed! (See License.txt for details)
6  */
7 
8 #pragma once
10 #include "EventProcessor.h"
11 #include <ace/INET_Addr.h>
12 #include <ace/Time_Value.h>
13 #include <QtCore/QString>
14 #include <QtCore/QDateTime>
15 
17 
19 {
20 public:
22  EVENT_DECL(evExpectClientRequest,0)
23  EVENT_DECL(evExpectClientResponse,1)
24  EVENT_DECL(evExpectMapClientRequest,2)
25  EVENT_DECL(evExpectMapClientResponse,3)
26  EVENT_DECL(evClientConnectionRequest,4)
27  EVENT_DECL(evClientConnectionResponse,5)
28  EVENT_DECL(evReloadConfig,6) // the server that receives this message will reload it's config file and restart with it
29 
30  EVENT_DECL(evGameServerStatus,10)
31  EVENT_DECL(evMapServerStatus,11)
32  // Message bus events
33  EVENT_DECL(evServiceStatus,101)
34  EVENT_DECL(evClientConnected,102)
35  EVENT_DECL(evClientDisconnected,103)
36  END_EVENTS(105)
37 };
38 
39 class InternalEvent : public SEGSEvent
40 {
41  uint64_t m_session_token = 0;
42 public:
43  using SEGSEvent::SEGSEvent; // forward all constructors to parent class.
44 
45  void session_token(uint64_t token) { m_session_token = token; }
46  uint64_t session_token() const { return m_session_token; }
47 
48 };
49 
50 #define ONE_WAY_MESSAGE(name)\
51 struct name ## Message final : public InternalEvent\
52 {\
53  name ## Data m_data;\
54  explicit name ## Message() : InternalEvent(Internal_EventTypes::ev ## name) {}\
55  name ## Message(name ## Data &&d) : InternalEvent(Internal_EventTypes::ev ## name),m_data(d) {}\
56 };
57 
59 #define SIMPLE_TWO_WAY_MESSAGE(name)\
60 struct name ## Request final : public InternalEvent\
61 {\
62  name ## Message(int token) : InternalEvent(Internal_EventTypes::ev ## name ## Request) {session_token(token);}\
63 };\
64 struct name ## Response final : public InternalEvent\
65 {\
66  name ## Data m_data;\
67  name ## Response(name ## Data &&d,uint64_t token) : InternalEvent(Internal_EventTypes::ev ## name ## Response),m_data(d) {session_token(token);}\
68 };
69 
71 #define TWO_WAY_MESSAGE(name)\
72 struct name ## Request final : public InternalEvent\
73 {\
74  name ## RequestData m_data;\
75  name ## Request(name ## RequestData &&d,uint64_t token) : InternalEvent(Internal_EventTypes::ev ## name ## Request),m_data(d) {session_token(token);}\
76 };\
77 struct name ## Response final : public InternalEvent\
78 {\
79  name ## ResponseData m_data;\
80  name ## Response(name ## ResponseData &&d,uint64_t token) : InternalEvent(Internal_EventTypes::ev ## name ## Response),m_data(d) {session_token(token);}\
81 };
82 
83 // This tells the server that it should expect a new client connection from given address
85 {
86  uint64_t m_client_id;
87  ACE_INET_Addr m_from_addr;
88  uint8_t m_access_level;
89 };
90 
91 // This event informs the server that given client is now expected on another server
92 // and passes that servers connection point, and connection cookie
94 {
95  uint64_t client_id;
96  uint32_t cookie;
97  uint32_t m_server_id; // this is the id of the server that is expecting the client
98 };
99 TWO_WAY_MESSAGE(ExpectClient)
100 
102 {
103  uint64_t m_client_id;
104  uint8_t m_access_level;
105  ACE_INET_Addr m_from_addr;
106  //TODO: pass this as POD, or serialize it into some internal format.
108  uint16_t m_slot_idx;
110  QString m_map_name;
111  uint16_t m_max_slots;
112 };
113 
115 {
116  uint32_t cookie;
117  uint32_t m_server_id; // this is the id of the server that is expecting the client
118  ACE_INET_Addr m_connection_addr; // this is the address that will be sent as a target connection pont to the client
119 };
120 TWO_WAY_MESSAGE(ExpectMapClient)
121 
122 // For now, no data here, could be a path to a config file?
124 {
125 
126 };
127 ONE_WAY_MESSAGE(ReloadConfig)
128 
130 {
131  ACE_INET_Addr m_addr;
134  uint16_t m_max_players;
135  uint8_t m_id;
136  bool m_online;
137 };
138 // This could be put in Message bus if any other server, apart from Auth needs this info.
139 ONE_WAY_MESSAGE(GameServerStatus)
140 
141 //
145 {
146  QString status_message;
148 };
149 ONE_WAY_MESSAGE(ServiceStatus)
150 
152 {
153  uint64_t m_session;
154  uint32_t m_server_id; // id of the server the client connected to.
155  uint32_t m_sub_server_id; // only used when server_id is the map server
156 };
157 ONE_WAY_MESSAGE(ClientConnected)
158 
160 {
161  uint64_t m_session;
162 };
163 ONE_WAY_MESSAGE(ClientDisconnected)
164 
165 #undef ONE_WAY_MESSAGE
166 #undef SIMPLE_TWO_WAY_MESSAGE
167 #undef TWO_WAY_MESSAGE
#define TWO_WAY_MESSAGE(name)
A message with Request having additional data.
Definition: InternalEvents.h:71
Definition: InternalEvents.h:123
uint8_t m_id
Definition: InternalEvents.h:135
uint32_t m_server_id
Definition: InternalEvents.h:97
#define BEGINE_EVENTS_INTERNAL()
Definition: SEGSEvent.h:18
Definition: SEGSEvent.h:32
QString m_map_name
Definition: InternalEvents.h:110
uint8_t m_access_level
Definition: InternalEvents.h:88
uint16_t m_slot_idx
Definition: InternalEvents.h:108
GameAccountResponseCharacterData * char_from_db
Definition: InternalEvents.h:107
void session_token(uint64_t token)
Definition: InternalEvents.h:45
Definition: InternalEvents.h:159
uint8_t m_access_level
Definition: InternalEvents.h:104
QString status_message
Definition: InternalEvents.h:146
The following messages are put on the global Message Bus, and published there for all subscribers to ...
Definition: InternalEvents.h:144
QString m_character_name
Definition: InternalEvents.h:109
uint64_t client_id
Definition: InternalEvents.h:95
#define END_EVENTS(cnt)
Definition: SEGSEvent.h:20
uint32_t m_server_id
Definition: InternalEvents.h:154
Definition: InternalEvents.h:18
Definition: InternalEvents.h:101
ACE_INET_Addr m_addr
Definition: InternalEvents.h:131
uint32_t m_sub_server_id
Definition: InternalEvents.h:155
uint32_t cookie
Definition: InternalEvents.h:116
uint16_t m_max_slots
Definition: InternalEvents.h:111
Definition: GameDBSyncEvents.h:130
uint32_t cookie
Definition: InternalEvents.h:96
uint64_t m_session
Definition: InternalEvents.h:153
QDateTime m_last_status_update
Definition: InternalEvents.h:132
Definition: InternalEvents.h:39
Definition: InternalEvents.h:151
uint32_t m_server_id
Definition: InternalEvents.h:117
uint64_t m_session
Definition: InternalEvents.h:161
uint16_t m_max_players
Definition: InternalEvents.h:134
int status_value
Definition: InternalEvents.h:147
Definition: InternalEvents.h:114
Definition: InternalEvents.h:93
Definition: InternalEvents.h:84
uint64_t m_client_id
Definition: InternalEvents.h:86
#define ONE_WAY_MESSAGE(name)
Definition: InternalEvents.h:50
ACE_INET_Addr m_from_addr
Definition: InternalEvents.h:105
uint64_t m_client_id
Definition: InternalEvents.h:103
ACE_INET_Addr m_from_addr
Definition: InternalEvents.h:87
SEGSEvent(uint32_t evtype, EventProcessor *ev_src=nullptr)
Definition: SEGSEvent.h:47
uint64_t session_token() const
Definition: InternalEvents.h:46
bool m_online
Definition: InternalEvents.h:136
uint16_t m_current_players
Definition: InternalEvents.h:133
#define EVENT_DECL(name, cnt)
Definition: SEGSEvent.h:19
ACE_INET_Addr m_connection_addr
Definition: InternalEvents.h:118
Definition: InternalEvents.h:129