Emergency 20 Dokumentation  4.2.0
NetworkManager.h
Go to the documentation of this file.
1 // Copyright (C) 2012-2018 Promotion Software GmbH
2 
3 
4 //[-------------------------------------------------------]
5 //[ Header guard ]
6 //[-------------------------------------------------------]
7 #pragma once
8 
9 
10 //[-------------------------------------------------------]
11 //[ Includes ]
12 //[-------------------------------------------------------]
14 
16 
18 
19 #include <boost/signals2/signal.hpp>
20 
21 
22 //[-------------------------------------------------------]
23 //[ Forward declarations ]
24 //[-------------------------------------------------------]
25 namespace em5
26 {
27  class UpdateCheck;
28  class MatchmakingClient;
29  class MapIdentifier;
30  namespace multiplayer
31  {
32  class SessionBase;
33  namespace server
34  {
35  class Host;
36  }
37  namespace client
38  {
39  class Client;
40  }
41  namespace proxy
42  {
43  class MultiplayerProxyClient;
44  }
45  }
46 }
47 
48 
49 //[-------------------------------------------------------]
50 //[ Namespace ]
51 //[-------------------------------------------------------]
52 namespace em5
53 {
54 
55 
56  //[-------------------------------------------------------]
57  //[ Classes ]
58  //[-------------------------------------------------------]
64  {
65 
66 
67  //[-------------------------------------------------------]
68  //[ Public definitions ]
69  //[-------------------------------------------------------]
70  public:
73 
74 
75  //[-------------------------------------------------------]
76  //[ Public boost signals ]
77  //[-------------------------------------------------------]
78  public:
79  boost::signals2::signal<void(multiplayer::SessionBase&)> sessionBaseInstanceCreated;
80 
81 
82  //[-------------------------------------------------------]
83  //[ Public static methods ]
84  //[-------------------------------------------------------]
85  public:
93  static std::string generateCurrentGameModificationString();
94 
95 
96  //[-------------------------------------------------------]
97  //[ Public methods ]
98  //[-------------------------------------------------------]
99  public:
104  NetworkManager();
105 
110  virtual ~NetworkManager();
111 
112  //[-------------------------------------------------------]
113  //[ Lifecycle ]
114  //[-------------------------------------------------------]
115  virtual bool onStartup() override;
116  virtual void onShutdown() override;
117 
118  //[-------------------------------------------------------]
119  //[ Matchmaking ]
120  //[-------------------------------------------------------]
133  void setMatchmakingUrlAndPort(const std::string& matchmakingUrl, uint16 matchmakingPort);
134 
145  std::shared_ptr<MatchmakingClient> connectToMatchmakingServer();
146 
154  std::shared_ptr<MatchmakingClient> getMatchmakingClient() const;
155 
156  //[-------------------------------------------------------]
157  //[ Multiplayer Client ]
158  //[-------------------------------------------------------]
166  multiplayer::client::Client* createMultiplayerClient();
167 
180  multiplayer::client::Client* connectToMultiplayerHost(const multiplayer::HostEntry& hostEntry, const std::string& playerName, const std::string& sessionPassword);
181 
192  multiplayer::client::Client* connectToLocalMultiplayerHost(const std::string& dataPath, const MapIdentifier& mapIdentifier, const std::string& playerName, const std::string& sessionPassword);
193 
201  multiplayer::client::Client* getMultiplayerClient() const;
202 
207  void closeMultiplayerClient();
208 
209  //[-------------------------------------------------------]
210  //[ Multiplayer Host ]
211  //[-------------------------------------------------------]
219  multiplayer::server::Host* createMultiplayerHost();
220 
228  multiplayer::server::Host* getMultiplayerHost() const;
229 
234  void closeMultiplayerHost();
235 
236  //[-------------------------------------------------------]
237  //[ Multiplayer General ]
238  //[-------------------------------------------------------]
243  bool isMultiplayActive() const;
244 
252  multiplayer::SessionBase* getMultiplayerSession() const;
253 
258  UpdateCheck& getUpdateCheck();
259 
260  //[-------------------------------------------------------]
261  //[ Multiplayer Proxy Client ]
262  //[-------------------------------------------------------]
272  void setProxyUrlAndPort(const std::string& proxyUrl, uint16 proxyPort);
273 
284  multiplayer::proxy::MultiplayerProxyClient* connectToMultiplayerProxyServer();
285 
301  multiplayer::proxy::MultiplayerProxyClient* connectToMultiplayerProxyServer(const std::string& hostname, uint16 port);
302 
310  multiplayer::proxy::MultiplayerProxyClient* getMultiplayerProxyClient() const;
311 
316  void closeMultiplayerProxyClient();
317 
318 
319  //[-------------------------------------------------------]
320  //[ Private data ]
321  //[-------------------------------------------------------]
322  private:
323  std::weak_ptr<MatchmakingClient> mMatchmakingClient;
324  multiplayer::client::Client* mMultiplayerClient;
325  multiplayer::server::Host* mMultiplayerHost;
326  multiplayer::proxy::MultiplayerProxyClient* mMultiplayerProxyClient;
327 
328  UpdateCheck* mUpdateCheck;
329 
330  boost::optional<std::string> mMatchmakingUrl;
331  boost::optional<uint16> mMatchmakingPort;
332  boost::optional<std::string> mProxyUrl;
333  boost::optional<uint16> mProxyPort;
334 
335 
336  };
337 
338 
339 //[-------------------------------------------------------]
340 //[ Namespace ]
341 //[-------------------------------------------------------]
342 } // em5
Definition: ActionPriority.h:13
#define EM5_API_EXPORT
Definition: Export.h:28
static const uint16 MULTIPLAYER_PROXY_SERVER_PORT
Definition: NetworkManager.h:72
EMERGENCY 5 update check class.
Definition: UpdateCheck.h:30
EMERGENCY 5 multiplayer host class.
Definition: Host.h:82
Unique instance interface.
Definition: UniqueInstance.h:34
static const uint16 MATCHMAKING_SERVER_PORT
Definition: NetworkManager.h:71
EMERGENCY 5 multiplayer session base class.
Definition: SessionBase.h:55
EMERGENCY 5 map identifier class.
Definition: MapIdentifier.h:34
Game network manager class.
Definition: NetworkManager.h:48
boost::signals2::signal< void(multiplayer::SessionBase &)> sessionBaseInstanceCreated
Definition: NetworkManager.h:79
unsigned short uint16
Definition: PlatformTypes.h:178
EMERGENCY 5 multiplayer proxy client class.
Definition: MultiplayerProxyClient.h:37
EMERGENCY 5 network manager class.
Definition: NetworkManager.h:63
EMERGENCY 5 multiplayer client class.
Definition: Client.h:69
Definition: MatchmakingTypes.h:47