ReplicaNet and RNLobby  1
StatServer.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 _STATSERVER_H_
13 #define _STATSERVER_H_
14 #include "RNPlatform/Inc/ThreadClass.h"
15 #include "RNLobby/Inc/RNLobby.h"
16 #include "RNLobby/Inc/BaseTransportServer.h"
17 #include "RNXPSockets/Inc/XPSocket.h"
18 #include "RNODBCSQL/Inc/ODBCSQL.h"
19 #include "RNODBCSQL/Inc/Prepare.h"
20 #include "RNLog/Inc/Log.h"
21 #include <map>
22 
23 namespace RNReplicaNet
24 {
25 
26 namespace RNLobby
27 {
28 
33 {
34 public:
35  StatServer(const char *lobbyDSN = MRNLobbyDefaultDSN);
36  virtual ~StatServer();
37 
38  enum
39  {
40  kDefaultPort = 4010
41  };
42 
44  bool Start(const XPAddress &address = XPAddress(kDefaultPort));
45 
47  size_t GetNumTotal(void) const;
48 
49  struct LoginIDData
50  {
51  std::map<std::string,std::string> mValuePairs;
52  };
53  struct SessionData
54  {
55 // std::string mSessionNonce;
56  std::map<int,LoginIDData> mDataByLoginID;
57  bool mClientOKToUpload;
58  int mGettingScriptID;
59  int mGettingTitleID;
60  bool mSessionStarted;
61  int mSessionScriptID;
62  int mSessionTitleID;
63  DynamicMessageHelper mScriptData;
64  int mCapturingLoginIDPairs;
65  };
66 
67 private:
68  RNReplicaNet::RNLog::Log mLog;
69 
70  RNODBCSQL::ODBCSQL mWrite;
71  RNODBCSQL::ODBCSQL mRead;
72  std::map<Transport *,SessionData> mMapSessionDataByTransport;
73  MutexClass mMapByTransportLock;
74 
75  size_t mNumActive;
76  size_t mNumTotal;
77 
78  RNODBCSQL::Prepare mPreparedCountStatAdminUsersByIDForTitleID;
79 
80  bool CallbackPoll(void);
81 
82  bool CallbackParseValidMessage(Transport *transport,DynamicMessageHelper &message,const size_t length);
83 
84  void CallbackAccepted(Transport *transport);
85 
86  void CallbackDisconnected(Transport *transport);
87 };
88 
89 } // namespace RNLobby
90 
91 } // namespace RNReplicaNet
92 
93 #endif
Definition: Transport.h:35
A server base class that handles encrypted messages to and from a transport.
Definition: BaseTransportServer.h:30
Definition: XPSocket.h:91
Definition: StatServer.h:32
bool Start(const XPAddress &address=XPAddress(kDefaultPort))
Because this uses a TransportUDP connection it will call XPURL::RegisterDefaultTransports() ...
size_t GetNumTotal(void) const
Returns the total number of stats sessions.
Definition: ThreadClass.h:39
Definition: MessageHelper.h:211