Main Page | Modules | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

DistributedNetworkObject Class Reference
[Distributed Network Object Subsystem]

Distributed Network Object base class. More...

#include <DistributedNetworkObject.h>

Inheritance diagram for DistributedNetworkObject:

NetworkObject List of all members.

Public Member Functions

 DistributedNetworkObject ()
virtual ~DistributedNetworkObject ()
virtual void UpdateDistributedObject (char *classID, bool isClassIDEncoded=false)
virtual void SetMaximumUpdateFrequency (unsigned long frequency)
virtual void DestroyObjectOnNetwork (void)
virtual bool AllowSpectatorUpdate (PlayerID sender)
void SynchronizeMemory (unsigned char memoryBlockIndex, char *memoryBlock, unsigned short memoryBlockSize, bool serverAuthority)
void DesynchronizeMemory (unsigned char memoryBlockIndex)
void SetAuthority (unsigned char memoryBlockIndex, bool serverAuthority)
bool IsMemoryBlockIndexUsed (unsigned char memoryBlockIndex)
void SetMaxMemoryBlockUpdateFrequency (unsigned char memoryBlockIndex, int max)
virtual void WriteCreationData (RakNet::BitStream *initialData)
virtual void ReadCreationData (RakNet::BitStream *initialData)
virtual void OnNetworkUpdate (PlayerID sender)
virtual bool OnDistributedObjectCreation (PlayerID senderID)
virtual void OnDistributedObjectDestruction (PlayerID senderID)
virtual void OnDistributedObjectRejection (void)
virtual void BroadcastSerializedClass (RakNet::BitStream *bitStream, PlayerID doNotSendTo)
virtual void SerializeClassHeader (RakNet::BitStream *bitStream, char *classIdentifier, int action, bool localObject, unsigned char localObjectIndex)
bool IsLocalObject (void) const
void SetLocalObject (bool b)
virtual bool ProcessDistributedMemoryStack (RakNet::BitStream *bitStream, bool isWrite, bool forceWrite, bool isServerAuthoritative)
bool WriteToBitstreamFromHeap (RakNet::BitStream *bitStream, bool forceWrite)
void WriteToHeapFromBitstream (RakNet::BitStream *bitStream)
unsigned char GetLocalObjectIdentifier (void) const
PlayerID GetClientOwnerID (void) const
void SetClientOwnerID (PlayerID id)

Static Public Member Functions

static bool DeserializeClassHeader (RakNet::BitStream *bitStream, int &action, ObjectID &objectId, char classIdentifier[MAXIMUM_CLASS_IDENTIFIER_LENGTH], bool &localObject, unsigned char &localObjectIndex, PlayerID &pid)

Protected Member Functions

virtual void DistributedMemoryInit (bool isServerAuthoritative)
virtual void InterpolateDistributedMemory (bool isServerAuthoritative)

Protected Attributes

unsigned long maximumUpdateFrequency
unsigned long lastBroadcastTime
bool localObject
unsigned char localObjectIdentifier
bool distributedMemoryInitialized
PlayerID clientOwnerID
struct {
   char *   watchedData
   char *   lastWriteValue
   int   allocatedBlockSize
   int   maximumUpdateInterval
   unsigned short   usedBlockSize
   bool   serverAuthority
   unsigned long   nextUpdateTime
heapNodeList [256]

Detailed Description

Distributed Network Object base class.

The ditributed Network Object System rely mostly on this class. It's the base class for all Distributed Object. You should specialize this class to define DNO objects.


Constructor & Destructor Documentation

DistributedNetworkObject::DistributedNetworkObject  ) 
 

Default Constructor

DistributedNetworkObject::~DistributedNetworkObject  )  [virtual]
 

Destructor


Member Function Documentation

bool DistributedNetworkObject::AllowSpectatorUpdate PlayerID  sender  )  [virtual]
 

Server only function By default, when a client creates an object only it can update the client authoritative members Of the class it creates. You can also set this manually with SetClientOwnerID This function is called when a client that does not own an object tries to change any fields in that object Return true to allow the update. Return false (default) to not allow the update.

void DistributedNetworkObject::BroadcastSerializedClass RakNet::BitStream bitStream,
PlayerID  doNotSendTo
[virtual]
 

-------------------------------------------------------------------------- All functions below are used by the API and do not need to be called or modified -------------------------------------------------------------------------- You don't need to modify this Sends the bitstream to other systems

bool DistributedNetworkObject::DeserializeClassHeader RakNet::BitStream bitStream,
int &  action,
ObjectID objectId,
char  classIdentifier[MAXIMUM_CLASS_IDENTIFIER_LENGTH],
bool &  localObject,
unsigned char &  localObjectIndex,
PlayerID pid
[static]
 

You don't need to modify this Writes the header identifying the class, objectID, and whether the object is being created or destroyed action of 0 means destruction, 1 means update, 2 means create

void DistributedNetworkObject::DestroyObjectOnNetwork void   )  [virtual]
 

This broadcasts a request to destroy an object on the network. OnDistrubtedObjectDestruction will be called. If you wish to block deletion, override OnDistributedObjectDestruction

void DistributedNetworkObject::DesynchronizeMemory unsigned char  memoryBlockIndex  ) 
 

Untags memory that was formerly synchronized.

void DistributedNetworkObject::DistributedMemoryInit bool  isServerAuthoritative  )  [protected, virtual]
 

You don't need to modify this Initializes distributed object the first time it is used

PlayerID DistributedNetworkObject::GetClientOwnerID void   )  const
 

This is set to who created this object. On the server, this also determines who can update the client authoritative members of this object. You can manually set it to UNASSIGNED_PLAYER_ID so no client owns the object, so any client can update the object.

unsigned char DistributedNetworkObject::GetLocalObjectIdentifier void   )  const
 

You don't need to modify this Returns the identifier for an object that has not yet had SetID called on it

void DistributedNetworkObject::InterpolateDistributedMemory bool  isServerAuthoritative  )  [protected, virtual]
 

You don't need to modify this Interpolates between all variables on the network that are set to interpolate. This function does not need to be modified by the end-user

bool DistributedNetworkObject::IsLocalObject void   )  const
 

You don't need to modify this Returns true if this object was locally created, as opposed to created by the network

bool DistributedNetworkObject::IsMemoryBlockIndexUsed unsigned char  memoryBlockIndex  ) 
 

Tells you if a block of memory was formerly used. You probably will never need this.

bool DistributedNetworkObject::OnDistributedObjectCreation PlayerID  senderID  )  [virtual]
 

This is called when the object is created by the network. Return true to accept the new object, false to reject it. The return value is primarily useful for the server to reject objects created by the client. On the client you would normally return true senderID is the playerID of the player that created the object (or the server, which you can get from RakClientInterface::GetServerID)

void DistributedNetworkObject::OnDistributedObjectDestruction PlayerID  senderID  )  [virtual]
 

This is called when the object is destroyed by the network. Default behavior is to delete itself. You can override this if you want to delete it elsewhere, or at a later time. If you don't delete the object, you should call DestroyObjectOnNetwork manually to remove it from the network Note it is important to override this on the server for objects you don't want clients to delete senderID is the playerID of the player that created the object (or the server, which you can get from RakClientInterface::GetServerID)

void DistributedNetworkObject::OnDistributedObjectRejection void   )  [virtual]
 

This is called when the server rejects an object the client created. Default behavior is to destroy the object. You can override this to destroy the object yourself.

void DistributedNetworkObject::OnNetworkUpdate PlayerID  sender  )  [virtual]
 

When distributed data changes for an object, this function gets called. Default behavior is to do nothing. Override it if you want to perform updates when data is changed On the server it is also important to override this to make sure the data the client just sent you is reasonable.

bool DistributedNetworkObject::ProcessDistributedMemoryStack RakNet::BitStream bitStream,
bool  isWrite,
bool  forceWrite,
bool  isServerAuthoritative
[virtual]
 

Writes to or reads from a bitstream for all distributed memory on the stack. This function does not need to be modified by the end-user Returns true if any data was written

void DistributedNetworkObject::ReadCreationData RakNet::BitStream initialData  )  [virtual]
 

When an object is created, ReadCreationData is called immediately after a successful call to OnDistributedObjectCreation This function is for you to read any data written from WriteCreationData on remote systems. If the object is created by the client, this function is also called by the creator of the object when sent back from the server in case the server overrode any settings

void DistributedNetworkObject::SerializeClassHeader RakNet::BitStream bitStream,
char *  classIdentifier,
int  action,
bool  localObject,
unsigned char  localObjectIndex
[virtual]
 

You don't need to modify this Writes the header identifying the class, objectID, and whether the object is being created or destroyed action of 0 means destruction, 1 means update, 2 means create

void DistributedNetworkObject::SetAuthority unsigned char  memoryBlockIndex,
bool  serverAuthority
 

Changes the authority for memory. You probably will never need this.

void DistributedNetworkObject::SetClientOwnerID PlayerID  id  ) 
 

This is set to who created this object. On the server, this also determines who can update the client authoritative members of this object. You can manually set it to UNASSIGNED_PLAYER_ID so no client owns the object, so any client can update the object.

void DistributedNetworkObject::SetLocalObject bool  b  ) 
 

You don't need to modify this Returns true if this object was locally created, as opposed to created by the network

void DistributedNetworkObject::SetMaximumUpdateFrequency unsigned long  frequency  )  [virtual]
 

Sets the maximum frequency with which memory synchronization packets can be sent. Lower values increase granularity but require more bandwidth

void DistributedNetworkObject::SetMaxMemoryBlockUpdateFrequency unsigned char  memoryBlockIndex,
int  max
 

Use this to set a maximum update frequency higher than what was specified to SetMaximumUpdateFrequency Lower values have no effect.

void DistributedNetworkObject::SynchronizeMemory unsigned char  memoryBlockIndex,
char *  memoryBlock,
unsigned short  memoryBlockSize,
bool  serverAuthority
 

Runtime memory synchronization

This system allows you to flag blocks of memory for synchronization between systems. This is different from REGISTER_X_DISTRIBUTED_OBJECT_MEMBERS in that you can set this up at runtime.

All synchronized blocks of memory are identified by a unique unsigned char. This char should match between systems for the same memory block. You can use any value for the identifier as long as it is unique.

Tags memory to be synchronized. You can set the server or the client as the authority for this block. Only the authority will write this memory to the network when it is changed.

void DistributedNetworkObject::UpdateDistributedObject char *  classID,
bool  isClassIDEncoded = false
[virtual]
 

Call this every update cycle for every distributed object that you want updated over the network and to interpolate classID should be a unique identifier for the class that matches the parameter to REGISTER_DISTRIBUTED_CLASS The obvious choice is the name of the class - however you can use something shorter if you wish to save a bit of bandwidth

void DistributedNetworkObject::WriteCreationData RakNet::BitStream initialData  )  [virtual]
 

-------------------------------------------------------------------------- Events -------------------------------------------------------------------------- When object creation data is needed, WriteCreationData is called. This function is for you to write any data that is needed to create or initialize the object On remote systems

bool DistributedNetworkObject::WriteToBitstreamFromHeap RakNet::BitStream bitStream,
bool  forceWrite
 

Same as ProcessDistributedMemoryStack with isWrite to false, but for the heapNodeList. Returns true if data was written

void DistributedNetworkObject::WriteToHeapFromBitstream RakNet::BitStream bitStream  ) 
 

Same as ProcessDistributedMemoryStack with isWrite to true, but for the heapNodeList.


Member Data Documentation

int DistributedNetworkObject::allocatedBlockSize [protected]
 

PlayerID DistributedNetworkObject::clientOwnerID [protected]
 

Which client is allowed to change the client authoritative members of this object

bool DistributedNetworkObject::distributedMemoryInitialized [protected]
 

This records if the distributed memory was initialized via DistributedMemoryInit

struct { ... } DistributedNetworkObject::heapNodeList[ 256 ] [protected]
 

unsigned long DistributedNetworkObject::lastBroadcastTime [protected]
 

lastBroadcastTime is the last time we sent a packet from this class

char* DistributedNetworkObject::lastWriteValue [protected]
 

bool DistributedNetworkObject::localObject [protected]
 

localObject means this object was created on the local system. If false, it means it was created by the network

unsigned char DistributedNetworkObject::localObjectIdentifier [protected]
 

If this is a local object, this identifies it uniquely

unsigned long DistributedNetworkObject::maximumUpdateFrequency [protected]
 

lastBroadcastTime is the last time we sent a packet from this class

int DistributedNetworkObject::maximumUpdateInterval [protected]
 

unsigned long DistributedNetworkObject::nextUpdateTime [protected]
 

bool DistributedNetworkObject::serverAuthority [protected]
 

unsigned short DistributedNetworkObject::usedBlockSize [protected]
 

char* DistributedNetworkObject::watchedData [protected]
 


The documentation for this class was generated from the following files:
Generated on Mon May 30 17:45:42 2005 for raknet by  doxygen 1.4.2