ReplicaNet and RNLobby
1
|
Maintains a connection to the StatServer. More...
#include <StatClient.h>
Public Member Functions | |
bool | Start (void) |
Because this uses a TransportUDP connection it will call XPURL::RegisterDefaultTransports() | |
void | SetServer (const XPAddress &address) |
bool | WantToUpload (const char *userNonce, const int scriptID) |
bool | UploadData (const void *data, const int size) |
bool | BeginSession (const int scriptID) |
Begins a statistics tracking session. | |
bool | UpdatePairsBegin (const char *userNonce) |
For a supplied user nonce begin updating value pairs. | |
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) | |
bool | UpdatePairsValue (const char *name, const int value) |
Sends a value pair to the server. The name is limited to 128 chars. (StatServerPrivate::kMaximumPairValueSize) | |
bool | UpdatePairsValue (const char *name, const float value) |
Sends a value pair to the server. The name is limited to 128 chars. (StatServerPrivate::kMaximumPairValueSize) | |
bool | UpdatePairsEnd (void) |
End updating the current batch of value pairs. | |
bool | EndSession (void) |
![]() | |
void | SetEncryptionKey (const void *data, const int length) |
virtual bool | StartWithTransport (Transport *transport, const bool allowDelete=true, const bool isListen=true) |
virtual bool | Stop (void) |
size_t | GetNumConnections (void) const |
Returns the number of active connections. | |
size_t | GetNumTotalSessions (void) const |
Returns the total number of connections. | |
bool | SetAsDisconnecting (Transport *transport) |
This will put the connection into a list pending disconnection after a timeout period. | |
![]() | |
ThreadClass () | |
virtual | ~ThreadClass () |
void | Sleep (int milliseconds) |
![]() | |
MutexClass () | |
virtual | ~MutexClass () |
void | Lock (void) |
void | UnLock (void) |
![]() | |
Thread () | |
virtual | ~Thread () |
void | Begin (ThreadClass *threaded_class) |
void | Terminate (void) |
bool | GetTerminated (void) |
bool | GetEverTerminated (void) |
bool | GetIsRunning (void) const |
void | SetPreferredProcessor (int processor=kReplicaNetPreferredProcessorOSChoice) |
int | GetPreferredProcessor (void) |
Protected Member Functions | |
virtual void | CallbackConnectionEstablished (Transport *transport) |
User extensible callbacks. More... | |
virtual void | CallbackUploadAuthenticationFailure (void) |
A virtual callback that is triggered when the userNonce from WantToUpload() fails the authentication check. | |
virtual void | CallbackUploadAuthenticationSuccess (void) |
A virtual callback that is triggered when the userNonce from WantToUpload() passes the authentication check. | |
virtual void | CallbackUploadACK (const int scriptID) |
A virtual callback that is triggered when UploadData() succeeds. | |
virtual void | CallbackBeginSession () |
A virtual callback that is triggered when the StatServer processes the BeginSession() request. | |
virtual void | CallbackEndSession () |
virtual void | CallbackEndSessionScriptNotFound () |
virtual void | CallbackEndSessionScriptNotCompleted () |
void | CallbackTidy (void) |
bool | CallbackPoll (void) |
bool | CallbackParseValidMessage (Transport *transport, DynamicMessageHelper &message, const size_t length) |
void | InitInternalState (void) |
![]() | |
virtual bool | PackageAndSendData (Transport *transport, const DynamicMessageHelper &message) |
The class mutex is locked during the context of this function. | |
virtual bool | CallbackParsePacketData (Transport *transport, void *data, size_t &length, DynamicMessageHelper &result, Entry &entry) |
virtual void | CallbackAccepted (Transport *transport) |
Called when the server accepts a connection or when a non-listen class instance connection gets a first valid reply from the server. | |
virtual void | CallbackDisconnected (Transport *transport) |
Called when the transport is disconnected. This is also called if there is a problem trying to connect. It is therefore possible for a non-listen class instance to receive this callback without a corresponding CallbackAccepted() | |
virtual void | CallbackDataReceived (DynamicMessageHelper &message) |
virtual void | CallbackDataSend (DynamicMessageHelper &message) |
virtual void | CallbackQueryReplyTime (const float seconds) |
int | ThreadEntry (void) |
void | GenerateNewNonce (void) |
int | GetConnectionNOnce (Transport *transport=0, const Entry *entry=0) |
Gets the connection's NOnce with respect to a Transport. | |
int | CalculateConnectionNOnce (Transport *transport) |
const Entry * | FindEntry (Transport *transport) |
![]() | |
void | DoQuitNow (const int returnCode) |
void | CheckQuit (void) |
Protected Attributes | |
XPAddress | mServerAddress |
bool | mServerAddressSet |
bool | mCanUpload |
bool | mInASession |
bool | mUpdatingPairs |
![]() | |
Transport * | mTransport |
bool | mAllowDelete |
int | mNOnce |
std::map< Transport *, Entry > | mConnected |
bool | mIsListen |
bool | mClientGotAPacket |
bool | mClientIsStable |
Entry | mClientEntry |
size_t | mNumConnections |
size_t | mNumTotalConnections |
Additional Inherited Members | |
![]() | |
enum | { kNoOwnerThread = -1 } |
![]() | |
static SysTimeType | FloatTime (void) |
![]() | |
static int | CallThreadEntry (ThreadClass *thread_class) |
static int | GetCurrentProcessorNumber (void) |
static size_t | GetNumAllocated (void) |
static size_t | GetNumActive (void) |
![]() | |
static size_t | GetNumAllocated (void) |
Maintains a connection to the StatServer.
|
inlineprotectedvirtual |
User extensible callbacks.
A virtual callback that is triggered when the StatClient connects the the StatServer.
|
inlineprotectedvirtual |
A virtual callback that is triggered when the StatServer has finished processing the session. Even if there is an error processing the session this callback is called.
|
inlineprotectedvirtual |
A virtual callback that is triggered when the StatServer is unable to complete a script. Most likely due to an exception or the script taking too long to execute. This is called before CallbackEndSession()
|
inlineprotectedvirtual |
A virtual callback that is triggered when the StatServer is unable to find the script. This is called before CallbackEndSession()
|
protectedvirtual |
Called from the scope of the thread but without the class mutex being locked. If a MessageHelper::Exception() is caught by this server class the connection will be terminated.
Reimplemented from BaseTransportServer.
|
protectedvirtual |
Called from the scope of the thread but without the class mutex being locked. This can be called with or without a valid mTransport
Reimplemented from BaseTransportServer.
|
protectedvirtual |
This callback may be used to tidy allocation of objects when the thread terminates. The class mutex is locked when executing this callback.
Reimplemented from BaseTransportServer.
bool EndSession | ( | void | ) |
End the statistics tracking session and start the script processing on the StatServer. On the StatServer for each authenticated player this calls the script function ProcessPlayer with the loginID in its own thread. The script function ProcessGame is also called once in its own thread. Each player and tracking session thread has an allocated 2000 script cycles to complete the work and update stats. It is a good idea to use the RNSimpleScriptDebugger to measure how many cycles each function takes. An example script, note the standard include header BootStat of the AsmBranch commands (each 5 bytes) for the script entry point. This BootStat file can instead be included first in the input file list.
#include <BootStat> DefProc ProcessPlayer(loginID) EndProc DefProc ProcessGame() EndProc
Using this standard script it is possible to use the debugger to call the second branch using the command line, using 5 (5 bytes for the AsmBranch) as the start address:
RNSimpleScriptDebugger.exe script.bin 5 script.bnd
void SetServer | ( | const XPAddress & | address | ) |
Sets the address and port of the server. The default for the instance of the class is localhost and port StatServer::kDefaultPort or the address resolved by a successful BackendClient::Start().
address | The new address and port number to use for the server |
bool UploadData | ( | const void * | data, |
const int | size | ||
) |
Following a successful request to WantToUpload() this function must be used to transfer script data to the server.
data | The data to send. |
size | The size of the data to send. Currently there is a limit of 64 kilobytes (65536 bytes) (StatServerPrivate::kMaximumScriptSize). |
bool WantToUpload | ( | const char * | userNonce, |
const int | scriptID | ||
) |
Using a user nonce, returned from UserClient::RequestUserNonce(), request to upload a script with the corresponding ID. CallbackUploadAuthenticationFailure() is called if the userNonce authentication fails. CallbackUploadAuthenticationSuccess() is called if the userNonce authentication succeeds.