BackendServer.h

00001 /* START_LICENSE_HEADER
00002 
00003 Copyright (C) 2000 Martin Piper, original design and program code
00004 Copyright (C) 2001 Replica Software
00005 
00006 This program file is copyright (C) Replica Software and can only be used under license.
00007 For more information visit: http://www.replicanet.com/
00008 Or email: info@replicanet.com
00009 
00010 END_LICENSE_HEADER */
00011 #ifndef _BACKENDSERVER_H_
00012 #define _BACKENDSERVER_H_
00013 #include "RNPlatform/Inc/DLLExportAPI.h"
00014 #include "RNPlatform/Inc/Encryption.h"
00015 #include "RNPlatform/Inc/ThreadClass.h"
00016 #include "RNPlatform/Inc/Thread.h"
00017 #include "RNXPSockets/Inc/XPSockets.h"
00018 #include "RNLobby/Inc/BaseServer.h"
00019 #include "RNODBCSQL/Inc/ODBCSQL.h"
00020 #include <map>
00021 #include <string>
00022 
00023 namespace RNReplicaNet
00024 {
00025 
00026 namespace RNLobby
00027 {
00028 
00032 class BackendServer : public BaseServer
00033 {
00034 public:
00035     BackendServer();
00036     virtual ~BackendServer();
00037 
00038     enum Reply
00039     {
00040         kReply_ValidTitleID = 0,
00041         kReply_InvalidTitleID,
00042         kReply_TitleIDSupportPeriodExpired,
00043         kReply_ServerDownForMaintanence,
00044         kReply_ServerCannotBeContacted
00045     };
00046     enum
00047     {
00048         kDefaultPort = 3000
00049     };
00050 
00053     bool Start(const XPAddress &address = XPAddress(kDefaultPort));
00054 
00055 private:
00056     void CallbackTidy(void);
00057 
00059     bool CallbackParseValidMessage(DynamicMessageHelper &message,const size_t length,const XPAddress &address);
00060 
00061     struct TitleIDInfo
00062     {
00063         std::string mKey;
00064         std::string mServers[2];
00065     };
00066 
00067     class BlockManager : public ThreadClass , public Thread
00068     {
00069     public:
00070         BlockManager();
00071         ~BlockManager();
00072 
00073         int ThreadEntry(void);
00074 
00075         void RefreshBlocks(void);
00076 
00077         bool FindTitleIDInfo(const int titleID,TitleIDInfo &info);
00078 
00079     private:
00080         RNODBCSQL::ODBCSQL mWrite;
00081         RNODBCSQL::ODBCSQL mRead;
00082 
00083         std::map<int,TitleIDInfo> mInfoList;
00084     };
00085 
00086     BlockManager mBlockManager;
00087 };
00088 
00089 } // namespace RNLobby
00090 
00091 } // namespace RNReplicaNet
00092 
00093 #endif

Generated on Sat Jun 28 22:02:16 2008 for ReplicaNet and RNLobby by  doxygen 1.5.3