ReplicaNet and RNLobby
1
|
A server base class that handles encrypted messages to and from a transport. More...
#include <BaseTransportServer.h>
Classes | |
struct | Entry |
Public Member Functions | |
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) |
Static Public Member Functions | |
static SysTimeType | FloatTime (void) |
![]() | |
static int | CallThreadEntry (ThreadClass *thread_class) |
static int | GetCurrentProcessorNumber (void) |
static size_t | GetNumAllocated (void) |
static size_t | GetNumActive (void) |
Protected Member Functions | |
virtual bool | CallbackParseValidMessage (Transport *transport, DynamicMessageHelper &message, const size_t length) |
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) |
virtual bool | CallbackPoll (void) |
virtual void | CallbackTidy (void) |
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 | |
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 size_t | GetNumAllocated (void) |
A server base class that handles encrypted messages to and from a transport.
|
inlineprotectedvirtual |
This callback may be used to alter data after it has been received and before the data received is processed.
message | The data held in a DynamicMessageHelper class. |
|
inlineprotectedvirtual |
This callback may be used to alter any data in a reply, just before it gets sent by the socket.
message | The data held in a DynamicMessageHelper class. |
|
protectedvirtual |
The class mutex is locked during the context of this function. The default operation is to decrypt the packet and then set result.SetGuardSize() with the size of the data and then call CallbackParseValidMessage(). This will cause a MessageHepler::Exception() exception to be thrown and may be caught by the user parser routines or will be caught by this server class.
result | The resultant data after decrypting and length will be updated with the new packet length. |
|
inlineprotectedvirtual |
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 in UserClient, AdvertiseClient, and StatClient.
|
inlineprotectedvirtual |
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 in UserClient, AdvertiseClient, and StatClient.
|
inlineprotectedvirtual |
This callback reports how long a query and reply took starting from when packet data was received until the packet data is sent.
seconds | The time in seconds. |
|
inlineprotectedvirtual |
This callback may be used to tidy allocation of objects when the thread terminates. The class mutex is locked when executing this callback.
Reimplemented in UserClient, AdvertiseClient, and StatClient.
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::BaseTransportServer querying this server.
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 |
Starts the thread. If this function is overridden then this base implementation must also be called.
transport | The transport to poll for this class. |
allowDelete | When true this class is responsible for deleting the socket. |
isListen | When true this class will listen for connections on the |
|
virtual |
Stops the thread. If this function is overridden then this base implementation must also be called. This will not generate CallbackDisconnected() events for any existing connections.
Reimplemented in UserClient.
|
protectedvirtual |
The thread starts executing from here.
Implements ThreadClass.