ReplicaNet and RNLobby  1
BackendServer.h
1 /* START_LICENSE_HEADER
2 
3 Copyright (C) 2000 Martin Piper, original design and program code
4 Copyright (C) 2001 Replica Software
5 
6 This program file is copyright (C) Replica Software and can only be used under license.
7 For more information visit: http://www.replicanet.com/
8 Or email: info@replicanet.com
9 
10 END_LICENSE_HEADER */
11 #include "RNPlatform/Inc/MemoryTracking.h"
12 #ifndef _BACKENDSERVER_H_
13 #define _BACKENDSERVER_H_
14 #include "RNPlatform/Inc/Encryption.h"
15 #include "RNPlatform/Inc/ThreadClass.h"
16 #include "RNPlatform/Inc/Thread.h"
17 #include "RNXPSockets/Inc/XPSockets.h"
18 #include "RNLobby/Inc/RNLobby.h"
19 #include "RNLobby/Inc/BaseServer.h"
20 #include "RNODBCSQL/Inc/ODBCSQL.h"
21 #include "RNLog/Inc/Log.h"
22 #include <map>
23 #include <string>
24 
25 namespace RNReplicaNet
26 {
27 
28 namespace RNLobby
29 {
30 
34 class BackendServer : public BaseServer
35 {
36 public:
37  BackendServer(const char *lobbyDSN = MRNLobbyDefaultDSN);
38  virtual ~BackendServer();
39 
40  enum Reply
41  {
42  kReply_InvalidTitleID = 0,
43  kReply_ValidTitleID,
44  kReply_TitleIDSupportPeriodExpired,
45  kReply_ServerDownForMaintanence,
46  kReply_ServerCannotBeContacted
47  };
48  enum
49  {
50  kDefaultPort = 4000,
51  kDefaultDebugPort = 4001
52  };
53 
56  bool Start(const XPAddress &address = XPAddress(kDefaultPort));
57 
58  static std::string TranslateReply(const Reply reply);
59 
60  struct TitleIDInfo
61  {
62  std::string mKey;
63  bool mSupportExpired;
64 
65  std::string mRLSrvAdvertiseAddress;
66  int mRLSrvAdvertisePort;
67  std::string mRLSrvAdvertiseCrypto;
68  std::string mRLSrvCodeAddress;
69  int mRLSrvCodePort;
70  std::string mRLSrvCodeCrypto;
71  std::string mRLSrvNATAddress;
72  int mRLSrvNATPort;
73  std::string mRLSrvNATCrypto;
74  std::string mRLSrvNATDetect1Address;
75  int mRLSrvNATDetect1Port;
76  std::string mRLSrvNATDetect2Address;
77  int mRLSrvNATDetect2Port;
78  std::string mRLSrvNATDetectCrypto;
79  std::string mRLSrvStatAddress;
80  int mRLSrvStatPort;
81  std::string mRLSrvStatCrypto;
82  std::string mRLSrvUserAddress;
83  int mRLSrvUserPort;
84  std::string mRLSrvUserCrypto;
85  std::string mRLSrvCloudAddress;
86  int mRLSrvCloudPort;
87  std::string mRLSrvCloudCrypto;
88  };
89 
90 private:
91  RNReplicaNet::RNLog::Log mLog;
92 
93  void CallbackTidy(void);
94 
96  bool CallbackParseValidMessage(DynamicMessageHelper &message,const size_t length,const XPAddress &address);
97 
98 
99 
100  class BlockManager : public ThreadClass , public Thread
101  {
102  public:
103  BlockManager(const char *lobbyDSN);
104  ~BlockManager();
105 
106  int ThreadEntry(void);
107 
108  void RefreshBlocks(void);
109 
110  bool FindTitleIDInfo(const int titleID,TitleIDInfo &info);
111 
112  private:
113  RNODBCSQL::ODBCSQL mWrite;
114  RNODBCSQL::ODBCSQL mRead;
115 
116  std::map<int,TitleIDInfo> mInfoList;
117  };
118 
119  BlockManager mBlockManager;
120 };
121 
122 } // namespace RNLobby
123 
124 } // namespace RNReplicaNet
125 
126 #endif
Definition: XPSocket.h:91
Definition: BackendServer.h:34
bool Start(const XPAddress &address=XPAddress(kDefaultPort))
Definition: MessageHelper.h:211
A server base class that handles encrypted messages to and from a socket.
Definition: BaseServer.h:24
Definition: ThreadClass.h:96
Definition: Thread.h:29