BaseTransportServer Class Reference

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

#include <BaseTransportServer.h>

Inheritance diagram for BaseTransportServer:

Inheritance graph
[legend]
Collaboration diagram for BaseTransportServer:

Collaboration graph
[legend]

List of all members.

Public Member Functions

void SetEncryptionKey (const void *data, const int length)
virtual bool Start (Transport *transport, const bool allowDelete=true, const bool isListen=true)
virtual bool Stop (void)
size_t GetNumConnections (void) const
bool SetAsDisconnecting (Transport *transport)
 This will put the connection into a list pending disconnection after a timeout period.

Static Public Member Functions

static float FloatTime (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)
virtual void CallbackAccepted (Transport *transport)
 Called when the server accepts a connection or when a non-listen class instance connection becomes stable.
virtual void CallbackDisconnected (Transport *transport)
 Called when the transport is disconnected.
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)

Protected Attributes

TransportmTransport
bool mAllowDelete
int mNOnce
std::map< Transport *,
Entry > 
mConnected
bool mIsListen
bool mClientIsStable
Entry mClientEntry
size_t mNumConnections

Classes

struct  Entry


Detailed Description

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

Member Function Documentation

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. 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 bool Start ( Transport transport,
const bool  allowDelete = true,
const bool  isListen = true 
) [virtual]

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

Parameters:
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
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. This will not generate CallbackDisconnected() events for any existing connections.

Returns:
Success returns true, failure returns false.

Reimplemented in UserClient.

virtual bool CallbackParseValidMessage ( Transport transport,
DynamicMessageHelper message,
const size_t  length 
) [inline, protected, virtual]

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 AdvertiseClient, and UserClient.

virtual bool CallbackParsePacketData ( Transport transport,
void *  data,
size_t &  length,
DynamicMessageHelper result 
) [protected, virtual]

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.

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

virtual void CallbackDataReceived ( DynamicMessageHelper message  )  [inline, protected, 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.

virtual void CallbackDataSend ( DynamicMessageHelper message  )  [inline, protected, 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.

virtual void CallbackQueryReplyTime ( const float  seconds  )  [inline, protected, 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, protected, virtual]

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 AdvertiseClient, and UserClient.

virtual void CallbackTidy ( void   )  [inline, protected, virtual]

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 AdvertiseClient, and UserClient.

int ThreadEntry ( void   )  [protected, virtual]

The thread starts executing from here.

Implements ThreadClass.


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