ReplicaNet and RNLobby
1
|
#include <DataBlock_Function.h>
Public Types | |
typedef void( | tDataBlock_Function_funcp )(void *classp, void *data, void *thisDataBlock) |
![]() | |
enum | ContinuityBreakTypes { kStop = 1, kSuddenChange = 2, kTeleport = 4 } |
Public Member Functions | |
RN_CLASS_MINIMAL_RTTI () | |
DataBlock_Function () | |
virtual | ~DataBlock_Function () |
virtual void | Poll (DataBlockReason *reason, const bool discardOlderIncluded=false, const unsigned int discardOrder=0) |
virtual void | ParseMessage (MessageHelper *message) |
void | RegisterInClassPointer (void *classp, tDataBlock_Function_funcp *funcp) |
void | AddFunctionStateChange (void *data, int len, const char *debug=0) |
bool | IsAttached (void *data) |
virtual void | OwnerChanged (const int sessionID) |
![]() | |
virtual int | GetThisClassType (void) |
DataBlock () | |
virtual | ~DataBlock () |
void | SetVariableName (const char *name=0) |
void | BindReplicaNet (ReplicaNet *current) |
void | BindReplicaObject (ReplicaObject *object) |
void | SetReliableFlag (bool reliable=false) |
bool | GetReliableFlag (void) const |
void | SetCertainFlag (bool certain=false) |
bool | GetCertainFlag (void) const |
void | SetOrderedFlag (bool ordered=false) |
bool | GetOrderedFlag (void) const |
void | SetDiscardOlder (const int windowBits=0) |
int | GetDiscardOlder (void) const |
void | SetAutomaticUpdatesFlag (bool automatic=true) |
bool | GetAutomaticUpdatesFlag (void) const |
virtual void | GiveDeltaHint (void *pdata, int dataLen) |
void | GiveDeltaHint (float delta) |
virtual void | ContinuityBreak (unsigned char breakTypes) |
void | SetForceReflectionUpdate (const bool enable=false) |
bool | GetForceReflectionUpdate (void) |
void | SetReflectionMasterUpdate (const bool enable=false) |
bool | GetReflectionMasterUpdate (void) |
virtual bool | IsAllocated (void) const |
void | SetIsAllocated (const bool isAllocated=true) |
void | SetUpdateDelayMinimum (const float delay=0.0f) |
float | GetUpdateDelayMinimum (void) const |
void | SetForceSendMaximumUpdates (const int updates=0) |
int | GetForceSendMaximumUpdates (void) const |
void | SetForceSendTimeDelay (const float delay=0.0f) |
float | GetForceSendTimeDelay (void) const |
void | SetBand (const unsigned int band=0) |
unsigned int | GetBand (void) const |
bool | ShouldDiscard (MessageHelper *message) |
bool | GetDiscardThisUpdate (void) const |
Static Public Member Functions | |
static DataBlock_Function * | Register (void *classp, tDataBlock_Function_funcp *funcp) |
static void | SetSessionIDFilter (const int numSessionIDs=0, const int *sessionIDs=0) |
Protected Member Functions | |
void | FreeSessionBlocks (void) |
![]() | |
void | SetID (int id) |
const char * | GetROName (ReplicaObject *from=0) |
void | EmitBaseDebugInfo (const char *name, const char *className, DataBlockReason *reason) |
void | EmitBaseDebugInfoUpdates (const char *name, const char *className, DataBlockReason *reason) |
std::string | GetVariableName (void) |
Protected Attributes | |
void * | mClassp |
tDataBlock_Function_funcp * | mData |
RegistryManagerMap< int, SessionBlock_Function > | mPerSessionFunction |
std::list< CombinedDataPacket * > | mFunctionStateChanges |
![]() | |
short | mID |
ReplicaNet * | mBoundReplicaNet |
ReplicaObject * | mBoundObject |
bool | mReliable |
bool | mCertain |
bool | mOrdered |
bool | mAutomaticUpdates |
bool | mIsAllocated |
bool | mDebugOn |
char * | mDebugText |
float | mUpdateDelayMinimum |
int | mForceSendMaximumUpdates |
float | mForceSendTimeDelay |
char * | mVariableName |
unsigned int | mBand |
int | mDiscardOlder |
unsigned int | mDiscardOlderMidPoint |
unsigned int | mDiscardOlderEndPoint |
size_t | mDiscardOlderRealSize |
unsigned int | mLocalisedOrderingSent |
unsigned int | mLocalisedOrderingReceived |
bool | mDiscardThisUpdate |
bool | mForceReflectionUpdate |
bool | mReflectionMasterUpdate |
Static Protected Attributes | |
static int | mConfiguredNumSessions |
static int * | mConfiguredSessionIDs |
This DataBlock derived class enables class member functions to be called on replicas of an object. Deleting a ReplicaObject derived class during a networked function call is not allowed. ReplicaObject::DelayedDelete() should be used instead. This will flag the object for a delete as soon as it is safe to do so.
This DataBlock does not do any latency compensation or prediction.
This DataBlock does not use the rules set by SetUpdateDelayMinimum() and SetForceSendMaximumUpdates() because the frequency of calling member functions and hence the frequency of DataBlock updates is defined by the application.
For security reasons only the master can send function calls to other replicas. A replica does not send any function updates to other replicas directly and will only send to the master. Therefore many of the macros, like ALL_REPLICAS_FUNCTION_CALL(), will operate differently depending on if the object is a master or a replica.
Before the object is published no network class member function calls will be propagated. Using these macros with an unpublished object will only cause the non-network portion to be executed, for example GLOBAL_FUNCTION_CALL will only call the function on the object.
You can use these macros to call network class member functions:
GLOBAL_FUNCTION_CALL()
Example: GLOBAL_FUNCTION_CALL(ASampleMemberFunction(foo,bar,wibble));
From a master this calls the function on the master and all replicas.
From a replica this only calls the function on the current replica and the master.
ALL_REPLICAS_FUNCTION_CALL()
Example: ALL_REPLICAS_FUNCTION_CALL(ASampleMemberFunction(foo));
From a master this calls the function on all replicas.
From a replica this only calls the function on the master.
MASTER_FUNCTION_CALL()
Example: MASTER_FUNCTION_CALL(ASampleMemberFunction(bar,wibble));
From a master this calls the function on all replicas.
From a replica this only calls the function on the master.
ONLY_MASTER_FUNCTION_CALL()
Example: ONLY_MASTER_FUNCTION_CALL(ASampleMemberFunction(bar,wibble));
From a master this calls the function only on the master.
From a replica this only calls the function on the master.
ALL_REPLICAS_FUNCTION_CALL() and MASTER_FUNCTION_CALL() have identical implementation, the naming is different to improve code readability.
NOMINATED_REPLICAS_FUNCTION_CALL()
Example: NOMINATED_REPLICAS_FUNCTION_CALL(numSessionIDs,sessionIDs,APublicFunction(random_int,random_float));
From a master this uses DataBlock_Function::SetSessionIDFilter() to propagate function calls to selected session IDs. From a replica this calls the function on the master regardless of the session ID list.
The ctor performs some basic initialisation
|
virtual |
The dtor makes sure everything is tidy
|
virtual |
Given a data pointer this function identifies if this data block is attached to the pointer.
Reimplemented from DataBlock.
|
virtual |
Called by ReplicaNet to indicate a change in owner. If this virtual method is implemented by a derived class the parent method must also be called.
Reimplemented from DataBlock.
|
virtual |
This parses a message for the derived class of this data block. If this virtual method is implemented by a derived class the parent method should be called. Implementation note: The same amount of data added to the message during the Poll() must equal the length of data retrieved during this function. Care must be taken when implementing functionality such as GetDiscardOlder() to preserve the length of data. Processing for this function may occur during the thread context of ReplicaNet so processing time used by this function should be kept to a minimum to avoid performance issues.
message | The current message buffer that contains the packet data |
Reimplemented from DataBlock.
|
virtual |
A poll function that is called by ReplicaNet to check for updates to this particular data block. If this virtual method is implemented by a derived class the parent method should be called before a data packet is created. Processing for this function may occur during the thread context of ReplicaNet so processing time used by this function should be kept to a minimum to avoid performance issues.
reason | the reason code that is passed in to this class to enable a response to be calculated |
discardOlderIncluded | When true and using SetDiscardOlder() this gives a hint to the DataBlock that the derived class has filled in a valid value for discardOrder. The default value is false and the DataBlock will use a global discard order seqeunce. |
discardOrder | When using SetDiscardOlder() and discardOlderIncluded is true this must contain a valid order sequence number for the update. The sequence should be unique for each target sessionID for the update. Since the sequence number is local for each target sessionID the window size for SetDiscardOlder() can be smaller. |
Reimplemented from DataBlock.
|
static |
This registers the memory area with this data block type and returns a new pointer
classp | is the pointer to this class that is passed through the message pipeline |
funcp | the actual function pointer to call that cracks the message |
|
inline |
This registers the memory area with this data block type. This is used when the memory is in datablocks that are allocated as part of a bigger class.
classp | is the pointer to this class that is passed through the message pipeline |
funcp | the actual function pointer to call that cracks the message |
|
static |
This configures the next networked function call from a master object to send the function call to the nominated sessionIDs. After the function call is completed all subsequent network function calls are sent without this filter unless this function is used. The NOMINATED_REPLICAS_FUNCTION_CALL() macro also uses this function.
Care must be taken when using this static function that multi-threaded ReplicaObject derived classes do not interrupt calls to this function and the subsequent network function call. The array pointed to by this function must persist until the subsequent network function call.
numSessionIDs | The number of session IDs in the array. |
sessionIDs | An array of session IDs that will receive the next network function call. |