SEGS  0.4.2
Super Entity Game Server
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HandlerLocator.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
9 #include <deque>
10 #include <stdint.h>
11 
12 class EventProcessor;
13 class MessageBus;
19 {
20  static MessageBus *m_message_bus;
21  static EventProcessor *m_db_sync_handler;
22  static EventProcessor *m_auth_handler;
23  static std::deque<EventProcessor *> m_game_servers;
24  static std::deque<EventProcessor *> m_map_servers;
25  static std::deque<EventProcessor *> m_game_db_servers;
26 public:
28  static void setMessageBus(MessageBus *h) { m_message_bus=h; }
29  static MessageBus *getMessageBus() { return m_message_bus; }
30 
31  static void setAuthDB_Handler(EventProcessor *h) { m_db_sync_handler=h; }
32  static EventProcessor *getAuthDB_Handler() { return m_db_sync_handler; }
33 
34  static void setAuth_Handler(EventProcessor *h) { m_auth_handler=h; }
35  static EventProcessor *getAuth_Handler() { return m_auth_handler; }
36 
37 
38  static const std::deque<EventProcessor *> &allGameDBHandlers() { return m_game_db_servers; }
39  static const std::deque<EventProcessor *> &allGameHandlers() { return m_game_servers; }
40  static EventProcessor *getGame_Handler(uint8_t id)
41  {
42  if(id>=m_game_servers.size())
43  return nullptr;
44  return m_game_servers[id];
45  }
46  static EventProcessor *getGame_DB_Handler(uint8_t id)
47  {
48  if(id>=m_game_db_servers.size())
49  return nullptr;
50  return m_game_db_servers[id];
51  }
52  static void setGame_Handler(uint8_t id,EventProcessor *h)
53  {
54  if(id>=m_game_servers.size())
55  m_game_servers.resize(id+1);
56  m_game_servers[id] = h;
57  }
58  static void setGame_DB_Handler(uint8_t id,EventProcessor *h)
59  {
60  if(id>=m_game_db_servers.size())
61  m_game_db_servers.resize(id+1);
62  m_game_db_servers[id] = h;
63  }
64  // The ID here must be the same as the GameServer ID
65  // the MapServer is the point of contact for the GameServer, and will create many MapInstances with running maps
66  static EventProcessor *getMap_Handler(uint8_t id)
67  {
68  if(id>=m_map_servers.size())
69  return nullptr;
70  return m_map_servers[id];
71  }
72  static void setMap_Handler(uint8_t id,EventProcessor *h)
73  {
74  if(id>=m_map_servers.size())
75  m_map_servers.resize(id+1);
76  m_map_servers[id] = h;
77  }
78 
79 };
80 extern void shutDownAllActiveHandlers();
static const std::deque< EventProcessor * > & allGameDBHandlers()
Definition: HandlerLocator.h:38
The HandlerLocator class is meant as a central point where each service registers it&#39;s presence...
Definition: HandlerLocator.h:18
static EventProcessor * getAuthDB_Handler()
Definition: HandlerLocator.h:32
static void setAuth_Handler(EventProcessor *h)
Definition: HandlerLocator.h:34
static void setMap_Handler(uint8_t id, EventProcessor *h)
Definition: HandlerLocator.h:72
static EventProcessor * getMap_Handler(uint8_t id)
Definition: HandlerLocator.h:66
void shutDownAllActiveHandlers()
Definition: HandlerLocator.cpp:26
static EventProcessor * getGame_Handler(uint8_t id)
Definition: HandlerLocator.h:40
static EventProcessor * getAuth_Handler()
Definition: HandlerLocator.h:35
static void setGame_DB_Handler(uint8_t id, EventProcessor *h)
Definition: HandlerLocator.h:58
static void setGame_Handler(uint8_t id, EventProcessor *h)
Definition: HandlerLocator.h:52
static void setAuthDB_Handler(EventProcessor *h)
Definition: HandlerLocator.h:31
static const std::deque< EventProcessor * > & allGameHandlers()
Definition: HandlerLocator.h:39
The MessageBus class is responsible for forwarding incoming events to correct subscriber&#39;s endpoints...
Definition: MessageBus.h:25
static void setMessageBus(MessageBus *h)
Definition: HandlerLocator.h:28
Definition: EventProcessor.h:13
static EventProcessor * getGame_DB_Handler(uint8_t id)
Definition: HandlerLocator.h:46
static MessageBus * getMessageBus()
Definition: HandlerLocator.h:29