BaseServer Class Reference

A server base class that handles encrypted messages to and from a socket. More...

#include <BaseServer.h>

Inheritance diagram for BaseServer:

Inheritance graph
[legend]
Collaboration diagram for BaseServer:

Collaboration graph
[legend]

List of all members.

Public Member Functions

virtual bool Start (t_XPSocket *socket, const bool allowDelete=true)
virtual bool Stop (void)
void SetEncryptionKey (const void *data, const int length)
virtual void CallbackDataReceived (DynamicMessageHelper &message, XPAddress &address)
virtual void CallbackDataSend (DynamicMessageHelper &message, XPAddress &address)
virtual void CallbackQueryReplyTime (const float seconds)
virtual bool CallbackPoll (void)
virtual void CallbackTidy (void)

Static Public Member Functions

static float FloatTime (void)

Protected Member Functions

virtual bool CallbackParseValidMessage (DynamicMessageHelper &message, const size_t length, const XPAddress &address)
virtual bool PackageAndSendData (t_XPSocket *socket, const DynamicMessageHelper &message, const XPAddress &address)
virtual bool CallbackParsePacketData (t_XPSocket *socket, const XPAddress &addr, void *data, size_t &length, DynamicMessageHelper &result)
int ThreadEntry (void)

Protected Attributes

t_XPSocket * mSocket
bool mAllowDelete
int mNOnce


Detailed Description

A server base class that handles encrypted messages to and from a socket.

Member Function Documentation

virtual bool Start ( t_XPSocket *  socket,
const bool  allowDelete = true 
) [virtual]

Starts the thread. If this function is overridden then this base implementation must also be called.

Parameters:
socket The socket to poll for this class.
allowDelete When true this class is responsible for deleting the socket.
Returns:
Success returns true, failure returns false.

virtual bool Stop ( void   )  [virtual]

Stops the thread. If this function is overridden then this base implementation must also be called.

Returns:
Success returns true, failure returns false.

void SetEncryptionKey ( const void *  data,
const int  length 
)

Sets the encryption key to be used by all queries for this server. The same key must be used with any other RNLobby::BaseServer querying this server. The default encryption key is the same for RNLobby::CodeServer and RNLobby::CodeClient.

Parameters:
data The data to use as a seed for the key. This can be NULL to use the default key.
length The length of the data to use for creating the key.

virtual void CallbackDataReceived ( DynamicMessageHelper message,
XPAddress address 
) [inline, virtual]

This callback may be used to alter data after it has been received and before the data received is processed.

Parameters:
message The data held in a DynamicMessageHelper class.
address The network address for this data packet. The contents of the address may be changed if required.

virtual void CallbackDataSend ( DynamicMessageHelper message,
XPAddress address 
) [inline, virtual]

This callback may be used to alter any data in a reply, just before it gets sent by the socket.

Parameters:
message The data held in a DynamicMessageHelper class.
address The network address for this data packet. The contents of the address may be changed if required.

virtual void CallbackQueryReplyTime ( const float  seconds  )  [inline, virtual]

This callback reports how long an query and reply took starting from when packet data was received until the packet data is sent.

Parameters:
seconds The time in seconds.

virtual bool CallbackPoll ( void   )  [inline, virtual]

Called from the scope of the thread but without the class mutex being locked.

Returns:
Return true to indicate this service class should continue to run. If false is returned this will stop the receiving thread and shutdown this server class.

virtual void CallbackTidy ( void   )  [inline, virtual]

This callback may be used to tidy allocation of objects when the thread terminates. The class mutex is locked when executing this callback.

virtual bool CallbackParseValidMessage ( DynamicMessageHelper message,
const size_t  length,
const XPAddress address 
) [inline, protected, virtual]

Called from the scope of the thread but without the class mutex being locked.

Returns:
Return true to indicate this service class should continue to run. If false is returned this will stop the receiving thread and shutdown this server class.

virtual bool PackageAndSendData ( t_XPSocket *  socket,
const DynamicMessageHelper message,
const XPAddress address 
) [protected, virtual]

The class mutex is locked during the context of this function.

Returns:
Return true to indicate this service class should continue to run. If false is returned this will stop the receiving thread and shutdown this server class.

virtual bool CallbackParsePacketData ( t_XPSocket *  socket,
const XPAddress addr,
void *  data,
size_t &  length,
DynamicMessageHelper result 
) [protected, virtual]

The class mutex is locked during the context of this function.

Parameters:
result The resultant data after decrypting and length will be updated with the new packet length.

int ThreadEntry ( void   )  [protected, virtual]

The thread starts executing from here.

Implements ThreadClass.


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