AdvertiseServer.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 _ADVERTISESERVER_H_
00012 #define _ADVERTISESERVER_H_
00013 #include "RNPlatform/Inc/DLLExportAPI.h"
00014 #include "RNPlatform/Inc/ThreadClass.h"
00015 #include "RNLobby/Inc/BaseTransportServer.h"
00016 #include "RNXPSockets/Inc/XPSocket.h"
00017 #include "RNODBCSQL/Inc/ODBCSQL.h"
00018 #include <map>
00019 
00020 namespace RNReplicaNet
00021 {
00022 
00023 namespace RNLobby
00024 {
00025 
00031 class AdvertiseServer : public BaseTransportServer
00032 {
00033 public:
00034     AdvertiseServer();
00035     virtual ~AdvertiseServer();
00036 
00037     enum
00038     {
00039         kDefaultPort = 3007
00040     };
00041 
00043     bool Start(const XPAddress &address = XPAddress(kDefaultPort));
00044 
00046     size_t GetNumActive(void) const;
00047 
00049     size_t GetNumTotal(void) const;
00050 
00051 private:
00052     bool CallbackPoll(void);
00053 
00054     bool CallbackParseValidMessage(Transport *transport,DynamicMessageHelper &message,const size_t length);
00055 
00056     int InsertEntry(const int titleID,const int loginID,const XPAddress &externalIP,const char *url=0,const char *userBlock = 0);
00057 
00058     bool UpdateEntry(const int index,const char *url = 0,const char *userBlock = 0);
00059 
00060     bool RemoveEntry(const int index);
00061 
00062     void CallbackAccepted(Transport *transport);
00063 
00064     void CallbackDisconnected(Transport *transport);
00065 
00066     RNODBCSQL::ODBCSQL mWrite;
00067     RNODBCSQL::ODBCSQL mRead;
00068     struct RuleInfo
00069     {
00070         RuleInfo(const std::string &rule,const std::string &data) : mRule(rule),mData(data) {}
00071         std::string mRule;
00072         std::string mData;
00073     };
00074     struct PlayerInfo
00075     {
00076         PlayerInfo(const std::string &name,const std::string &data,int loginID) : mName(name),mData(data),mLoginID(loginID){}
00077         std::string mName;
00078         std::string mData;
00079         int mLoginID;
00080     };
00081     struct SessionData
00082     {
00083         SessionData();
00084         int mDBIndex;
00085         XPAddress mExternalIP;
00086         int mConnectionNOnce;
00087 
00088         // Temporary storage while an update is being received until the end packet then this gets stored into the DB
00089         std::list<RuleInfo> mRules;
00090         std::list<PlayerInfo> mPlayers;
00091     };
00092     std::map<Transport *,SessionData> mMapByTransport;
00093     std::map<int,Transport *> mMapByIndex;
00094 
00095     size_t mNumActive;
00096     size_t mNumTotal;
00097 };
00098 
00099 } // namespace RNLobby
00100 
00101 } // namespace RNReplicaNet
00102 
00103 #endif

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