ReplicaNet and RNLobby  1
StatClient.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 _STATCLIENT_H_
13 #define _STATCLIENT_H_
14 #include "RNLobby/Inc/BaseTransportServer.h"
15 #include "RNXPSockets/Inc/XPSocket.h"
16 #include <list>
17 
18 namespace RNReplicaNet
19 {
20 
21 namespace RNLobby
22 {
23 
26 {
27 public:
28  StatClient();
29  virtual ~StatClient();
30 
32  bool Start(void);
33 
36  void SetServer(const XPAddress &address);
37 
41  bool WantToUpload(const char *userNonce, const int scriptID);
42 
46  bool UploadData(const void *data,const int size);
47 
49  bool BeginSession(const int scriptID);
50 
52  bool UpdatePairsBegin(const char *userNonce);
54  bool UpdatePairsValue(const char *name,const char *value = 0);
56  bool UpdatePairsValue(const char *name,const int value);
58  bool UpdatePairsValue(const char *name,const float value);
60  bool UpdatePairsEnd(void);
61 
79  bool EndSession(void);
80 
81 protected:
82 
84 
86  virtual void CallbackConnectionEstablished(Transport *transport) {}
87 
90 
93 
95  virtual void CallbackUploadACK(const int scriptID) {}
96 
98  virtual void CallbackBeginSession() {}
99 
102  virtual void CallbackEndSession() {}
103 
107 
111 
112 protected:
113  // These callbacks from BaseTransportServer are implemented by this class. If they are implemented by the user this implementation must be called.
114  void CallbackTidy(void);
115 
116  bool CallbackPoll(void);
117 
118  bool CallbackParseValidMessage(Transport *transport,DynamicMessageHelper &message,const size_t length);
119 
120  void InitInternalState(void);
121 
122  XPAddress mServerAddress;
123  bool mServerAddressSet;
124 
125  bool mCanUpload;
126 
127  bool mInASession;
128  bool mUpdatingPairs;
129 };
130 
131 } // namespace RNLobby
132 
133 } // namespace RNReplicaNet
134 
135 #endif
bool UpdatePairsValue(const char *name, const char *value=0)
Sends a value pair to the server. The name and value string is limited to 128 chars. (StatServerPrivate::kMaximumPairValueSize)
Definition: Transport.h:35
bool BeginSession(const int scriptID)
Begins a statistics tracking session.
A server base class that handles encrypted messages to and from a transport.
Definition: BaseTransportServer.h:30
Definition: XPSocket.h:91
virtual void CallbackUploadACK(const int scriptID)
A virtual callback that is triggered when UploadData() succeeds.
Definition: StatClient.h:95
Maintains a connection to the StatServer.
Definition: StatClient.h:25
virtual void CallbackBeginSession()
A virtual callback that is triggered when the StatServer processes the BeginSession() request...
Definition: StatClient.h:98
virtual void CallbackEndSessionScriptNotFound()
Definition: StatClient.h:106
bool Start(void)
Because this uses a TransportUDP connection it will call XPURL::RegisterDefaultTransports() ...
virtual void CallbackUploadAuthenticationSuccess(void)
A virtual callback that is triggered when the userNonce from WantToUpload() passes the authentication...
Definition: StatClient.h:92
bool UpdatePairsEnd(void)
End updating the current batch of value pairs.
bool UpdatePairsBegin(const char *userNonce)
For a supplied user nonce begin updating value pairs.
virtual void CallbackUploadAuthenticationFailure(void)
A virtual callback that is triggered when the userNonce from WantToUpload() fails the authentication ...
Definition: StatClient.h:89
bool UploadData(const void *data, const int size)
virtual void CallbackEndSession()
Definition: StatClient.h:102
virtual void CallbackEndSessionScriptNotCompleted()
Definition: StatClient.h:110
bool WantToUpload(const char *userNonce, const int scriptID)
Definition: MessageHelper.h:211
bool CallbackParseValidMessage(Transport *transport, DynamicMessageHelper &message, const size_t length)
virtual void CallbackConnectionEstablished(Transport *transport)
User extensible callbacks.
Definition: StatClient.h:86
void SetServer(const XPAddress &address)