SEGS  0.6.1-develop [3e741b81]
Super Entity Game Server
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 - 2019 SEGS Team (see AUTHORS.md)
5  * This software is licensed under the terms of the 3-clause BSD License. See LICENSE.md 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 #include <glm/vec3.hpp>
17 
18 namespace SEGSEvents
19 {
20 struct GameAccountResponseCharacterData;
21 
23 {
31  evReloadConfigMessage, //,6) // the server that receives this message will reload it's config file and restart with it
36  // Message bus events
41 };
42 
43 class InternalEvent : public Event
44 {
45  uint64_t m_session_token = 0;
46 public:
47  using Event::Event; // forward all constructors to parent class.
48 
49  void session_token(uint64_t token) { m_session_token = token; }
50  uint64_t session_token() const { return m_session_token; }
51 
52 };
53 
54 #define ONE_WAY_MESSAGE(enum_name,name)\
55 struct name ## Message final : public InternalEvent\
56 {\
57  name ## Data m_data;\
58  explicit name ## Message() : InternalEvent(enum_name::ev ## name ## Message) {}\
59  name ## Message(name ## Data &&d,uint64_t token,EventProcessor *ev_src=nullptr) : \
60  InternalEvent(enum_name::ev ## name ## Message) , m_data(std::move(d)) {\
61  session_token(token); src(ev_src);}\
62  EVENT_IMPL(name ## Message)\
63 };
64 
66 #define TWO_WAY_MESSAGE(enum_name,name)\
67 struct name ## Request final : public InternalEvent\
68 {\
69  name ## RequestData m_data;\
70  name ## Request(name ## RequestData &&d,uint64_t token,EventProcessor *ev_src=nullptr) : \
71  InternalEvent(enum_name::ev ## name ## Request) , m_data(std::move(d)) {\
72  session_token(token); src(ev_src);}\
73  /* needed for serialization functions */\
74  explicit name ## Request() : InternalEvent(enum_name::ev ## name ## Request) {}\
75  EVENT_IMPL(name ## Request)\
76 };\
77 struct name ## Response final : public InternalEvent\
78 {\
79  name ## ResponseData m_data;\
80  name ## Response(name ## ResponseData &&d,uint64_t token) : InternalEvent(enum_name::ev ## name ## Response),m_data(std::move(d)) {session_token(token);}\
81  /* needed for serialization functions */\
82  explicit name ## Response() : InternalEvent(enum_name::ev ## name ## Response) {}\
83  EVENT_IMPL(name ## Response)\
84 };
85 
86 // This tells the server that it should expect a new client connection from given address
88 {
89  ACE_INET_Addr m_from_addr;
90  uint32_t m_client_id;
91  uint8_t m_access_level;
92  template<class Archive>
93  void serialize(Archive &ar)
94  {
95  ar(m_from_addr,m_client_id,m_access_level);
96  }
97 };
98 
99 // This event informs the server that given client is now expected on another server
100 // and passes that servers connection point, and connection cookie
102 {
103  uint64_t client_id;
104  uint32_t cookie;
105  uint32_t m_server_id; // this is the id of the server that is expecting the client
106  template<class Archive>
107  void serialize(Archive &ar)
108  {
109  ar(client_id,cookie,m_server_id);
110  }
111 };
112 //[[ev_def:macro]]
114 
116 {
117  uint64_t m_client_id;
118  uint8_t m_access_level;
119  ACE_INET_Addr m_from_addr;
121  uint16_t m_slot_idx;
123  QString m_map_name;
124  uint16_t m_max_slots;
125  template<class Archive>
126  void serialize(Archive &ar)
127  {
128  ar(m_client_id,m_access_level,m_from_addr,char_from_db_data,
129  m_slot_idx,m_character_name,m_map_name,m_max_slots);
130  }
131 };
132 
134 {
135  uint32_t cookie;
136  uint32_t m_server_id; // this is the id of the server that is expecting the client
137  ACE_INET_Addr m_connection_addr; // this is the address that will be sent as a target connection pont to the client
138  template<class Archive>
139  void serialize(Archive &ar)
140  {
141  ar(cookie,m_server_id,m_connection_addr);
142  }
143 };
144 //[[ev_def:macro]]
145 TWO_WAY_MESSAGE(Internal_EventTypes,ExpectMapClient)
146 
147 // For now, no data here, could be a path to a config file?
149 {
150 
151  template<class Archive>
152  void serialize(Archive &)
153  {
154  }
155 };
156 //[[ev_def:macro]]
158 
160 {
161  ACE_INET_Addr m_addr;
164  uint16_t m_max_players;
165  uint8_t m_id;
166  bool m_online;
167  template<class Archive>
168  void serialize(Archive &ar)
169  {
170  ar(m_addr,m_last_status_update,m_current_players,m_max_players,m_id,m_online);
171  }
172 };
173 // This could be put in Message bus if any other server, apart from Auth needs this info.
174 //[[ev_def:macro]]
175 ONE_WAY_MESSAGE(Internal_EventTypes,GameServerStatus)
176 
177 //
181 {
182  QString status_message;
184  template<class Archive>
185  void serialize(Archive &ar)
186  {
187  ar(status_message,status_value);
188  }
189 };
190 //[[ev_def:macro]]
192 
194 {
195  uint64_t m_session;
196  uint32_t m_server_id; // id of the server the client connected to.
197  uint32_t m_sub_server_id; // only used when server_id is the map server
198  uint32_t m_char_db_id; // id of the character connecting
199  template<class Archive>
200  void serialize(Archive &ar)
201  {
202  ar(m_session,m_server_id,m_sub_server_id,m_char_db_id);
203  }
204 };
205 //[[ev_def:macro]]
206 ONE_WAY_MESSAGE(Internal_EventTypes,ClientConnected)
207 
209 {
210  uint64_t m_session;
211  uint32_t m_char_db_id; // id of the character disconnected
212  template<class Archive>
213  void serialize(Archive &ar)
214  {
215  ar(m_session,m_char_db_id);
216  }
217 };
218 //[[ev_def:macro]]
219 ONE_WAY_MESSAGE(Internal_EventTypes,ClientDisconnected)
220 
222 {
223  uint64_t m_session;
225  template<class Archive>
226  void serialize(Archive &ar)
227  {
228  ar(m_session, m_map_data);
229  }
230 };
231 // [[ev_def:macro]]
233 
235 {
236  uint32_t m_ent_db_id;
237  glm::vec3 m_pos;
238  QString m_node_name;
239  template<class Archive>
240  void serialize(Archive &ar)
241  {
242  ar(m_ent_db_id, m_pos, m_node_name);
243  }
244 };
245 // [[ev_def:macro]]
246 ONE_WAY_MESSAGE(Internal_EventTypes,MapSwapCollision)
247 
248 } // end of SEGSEvents namespace
Definition: InternalEvents.h:43
Definition: InternalEvents.h:37
uint16_t m_current_players
Definition: InternalEvents.h:163
glm::vec3 m_pos
Definition: InternalEvents.h:237
The following messages are put on the global Message Bus, and published there for all subscribers to ...
Definition: InternalEvents.h:180
Definition: InternalEvents.h:159
void serialize(Archive &ar)
Definition: InternalEvents.h:168
uint32_t m_sub_server_id
Definition: InternalEvents.h:197
uint64_t client_id
Definition: InternalEvents.h:103
void serialize(Archive &ar)
Definition: InternalEvents.h:200
Definition: InternalEvents.h:39
Definition: InternalEvents.h:25
uint32_t m_server_id
Definition: InternalEvents.h:105
uint64_t m_client_id
Definition: InternalEvents.h:117
QString status_message
Definition: InternalEvents.h:182
Event(uint32_t evtype, EventSrc *ev_src=nullptr)
Definition: SEGSEvent.h:50
QString m_node_name
Definition: InternalEvents.h:238
Definition: InternalEvents.h:26
MapXferData m_map_data
Definition: InternalEvents.h:224
Definition: InternalEvents.h:234
void serialize(Archive &)
Definition: InternalEvents.h:152
Definition: SEGSEvent.h:35
uint32_t cookie
Definition: InternalEvents.h:104
Definition: InternalEvents.h:28
uint16_t m_max_slots
Definition: InternalEvents.h:124
void serialize(Archive &ar)
Definition: InternalEvents.h:185
uint64_t m_session
Definition: InternalEvents.h:210
ACE_INET_Addr m_from_addr
Definition: InternalEvents.h:119
Definition: LinkLevelEvent.h:13
void serialize(Archive &ar)
Definition: InternalEvents.h:93
QString char_from_db_data
Definition: InternalEvents.h:120
#define END_EVENTS(enum_name, cnt)
Definition: SEGSEvent.h:24
uint32_t cookie
Definition: InternalEvents.h:135
Definition: InternalEvents.h:38
Definition: InternalEvents.h:115
Internal_EventTypes
Definition: InternalEvents.h:22
Definition: InternalEvents.h:208
Definition: InternalEvents.h:35
Definition: InternalEvents.h:32
int status_value
Definition: InternalEvents.h:183
uint64_t m_session
Definition: InternalEvents.h:195
bool m_online
Definition: InternalEvents.h:166
uint16_t m_slot_idx
serialized character data, if this is empty Map server assumes a new character
Definition: InternalEvents.h:121
uint32_t m_char_db_id
Definition: InternalEvents.h:198
#define TWO_WAY_MESSAGE(enum_name, name)
A message with Request having additional data.
Definition: InternalEvents.h:66
uint32_t m_server_id
Definition: InternalEvents.h:196
uint32_t m_server_id
Definition: InternalEvents.h:136
Definition: InternalEvents.h:87
uint8_t m_id
Definition: InternalEvents.h:165
QString m_map_name
Definition: InternalEvents.h:123
QString m_character_name
Definition: InternalEvents.h:122
QDateTime m_last_status_update
Definition: InternalEvents.h:162
void session_token(uint64_t token)
Definition: InternalEvents.h:49
ACE_INET_Addr m_connection_addr
Definition: InternalEvents.h:137
Definition: InternalEvents.h:101
Definition: InternalEvents.h:34
Definition: InternalEvents.h:148
#define BEGINE_EVENTS_INTERNAL(enum_name)
Definition: SEGSEvent.h:22
uint16_t m_max_players
Definition: InternalEvents.h:164
#define ONE_WAY_MESSAGE(enum_name, name)
Definition: InternalEvents.h:54
Definition: InternalEvents.h:29
Definition: InternalEvents.h:30
uint32_t m_ent_db_id
Definition: InternalEvents.h:236
void serialize(Archive &ar)
Definition: InternalEvents.h:213
void serialize(Archive &ar)
Definition: InternalEvents.h:107
uint32_t m_char_db_id
Definition: InternalEvents.h:211
Definition: map_definitions.h:41
ACE_INET_Addr m_addr
Definition: InternalEvents.h:161
uint64_t session_token() const
Definition: InternalEvents.h:50
uint32_t m_client_id
Definition: InternalEvents.h:90
Definition: InternalEvents.h:193
void serialize(Archive &ar)
Definition: InternalEvents.h:226
void serialize(Archive &ar)
Definition: InternalEvents.h:139
ACE_INET_Addr m_from_addr
Definition: InternalEvents.h:89
uint8_t m_access_level
Definition: InternalEvents.h:118
uint64_t m_session
Definition: InternalEvents.h:223
void serialize(Archive &ar)
Definition: InternalEvents.h:126
Definition: InternalEvents.h:31
void serialize(Archive &ar)
Definition: InternalEvents.h:240
Definition: InternalEvents.h:133
Definition: InternalEvents.h:27
uint8_t m_access_level
Definition: InternalEvents.h:91
Definition: InternalEvents.h:33
Definition: InternalEvents.h:221