ReplicatedObject Class Reference
[Data Replicator Subsystem]

This class provides an interface so RakNet can do object initial serializations and notifications of scope changes. More...

#include <DataReplicator.h>

Inheritance diagram for ReplicatedObject:

NetworkIDGenerator List of all members.

Public Member Functions

virtual bool InScope (PlayerID playerId, DataReplicator *dataReplicator)
virtual void OnScopeChange (PlayerID sender, bool isNowInScope, DataReplicator *dataReplicator)
virtual bool AcceptDereplicationRequest (PlayerID sender, DataReplicator *dataReplicator)
virtual void OnReplication (DataReplicator *dataReplicator)
 Convenience function called once, when the object is synchronized. If the object contains synchronized memory, this function is a good placeto call SynchronizeMemory.
virtual void OnRemoteDereplication (DataReplicator *dataReplicator)
virtual char * GetObjectClassName (void) const =0
virtual bool OnReceiveCreationRequest (PlayerID sender, RakNet::BitStream *inContext, RakNet::BitStream *outContext, PlayerID &objectOwner, DataReplicator *dataReplicator)
virtual bool OnCreationRequestAcceptance (PlayerID sender, ObjectID newObjectId, RakNet::BitStream *inContext, PlayerID &objectOwner, DataReplicator *dataReplicator)
virtual void OnCreationRequestRejection (PlayerID sender, RakNet::BitStream *inContext, DataReplicator *dataReplicator)
virtual ObjectReplicationPushResult OnSendCreationRequest (PlayerID destination, RakNet::BitStream *outContext, DataReplicator *dataReplicator)
virtual ObjectReplicationPushResult OnSendReplicationPush (PlayerID destination, RakNet::BitStream *outContext, DataReplicator *dataReplicator)
virtual bool OnReceiveReplicationPush (PlayerID sender, RakNet::BitStream *inContext, ObjectID newObjectId, PlayerID &objectOwner, DataReplicator *dataReplicator)
void SetOwner (PlayerID _owner)
PlayerID GetOwner (void) const
bool GetWaitingForCreationResponse (void)
virtual PlayerID GetNetworkIDAuthority (void) const =0
virtual bool IsNetworkIDAuthority (void) const =0

Protected Attributes

PlayerID owner

Detailed Description

This class provides an interface so RakNet can do object initial serializations and notifications of scope changes.


Member Function Documentation

bool ReplicatedObject::AcceptDereplicationRequest PlayerID  sender,
DataReplicator dataReplicator
[virtual]
 

A remote system has Unsynchronized an object and is notifying us of the desynchronizationIf you return true the DataReplicator will stop sending updates to that system if we send updates.If we do not send updates and we receive updates, the object will be Unsynchronized. Note that the object is not deleted.

Parameters:
[in] sender The remote system
[in] dataReplicator The instance of the DataReplicator class this object was synchronized with.
Returns:
true to accept the deletion, false to ignore it.

virtual PlayerID ReplicatedObject::GetNetworkIDAuthority void   )  const [pure virtual]
 

For every group of systems, one system needs to be responsible for creating unique IDs for all objects created on all systems.This way, systems can send that id in packets to refer to objects (you can't send pointers because the memory allocations may be different).You must override this function to return the playerID of that system.

Returns:
PlayerID of the network ID assigning system.

virtual char* ReplicatedObject::GetObjectClassName void   )  const [pure virtual]
 

Return the name of the class of this object.

Returns:
class name.

PlayerID ReplicatedObject::GetOwner void   )  const
 

Gets the owner

Returns:
The value passed to SetOwner

bool ReplicatedObject::GetWaitingForCreationResponse void   ) 
 

Returns if this object is waiting for a response from the network ID authority to see if it can be created.

Returns:
if this object is waiting for a request creation response.

bool ReplicatedObject::InScope PlayerID  playerId,
DataReplicator dataReplicator
[virtual]
 

Return true if this object is in-scope relevant to the system designated by playerId

Parameters:
[in] playerId The remote system
[in] dataReplicator The instance of the DataReplicator class this object was synchronized with.
Returns:
true if this object is in-scope relevant to the system designated by playerId.

virtual bool ReplicatedObject::IsNetworkIDAuthority void   )  const [pure virtual]
 

For every group of systems, one system needs to be responsible for creating unique IDs for all objects created on all systems.This way, systems can send that id in packets to refer to objects (you can't send pointers because the memory allocations may be different).In a client/server enviroment, the system that creates unique IDs would be the server.If this system is responsible for creating unique IDs, return true. Otherwise return false.

Returns:
true if this is the server, or a hosting peer. Otherwise false.

Implements NetworkIDGenerator.

bool ReplicatedObject::OnCreationRequestAcceptance PlayerID  sender,
ObjectID  newObjectId,
RakNet::BitStream inContext,
PlayerID objectOwner,
DataReplicator dataReplicator
[virtual]
 

Our request to create an object has been accepted.

Parameters:
[in] sender The remote system
[in] newObjectId The object ID of the new object. You can set this yourself, or it will be set after the function returns if you do not.
[in] inContext The outContext reply from OnCreationRequest
[in] objectOwner [OutParam] Which system owns the object, assuming it is created. If you don't set this it defaults to this system
[in] dataReplicator The instance of the DataReplicator class this object was synchronized with.
Returns:
true to accept final creation of this class, false to delete it.

void ReplicatedObject::OnCreationRequestRejection PlayerID  sender,
RakNet::BitStream inContext,
DataReplicator dataReplicator
[virtual]
 

Our request to create an object has been rejected.

Parameters:
[in] sender The remote system
[in] inContext The outContext reply from OnCreationRequest
[in] dataReplicator The instance of the DataReplicator class this object was synchronized with.

bool ReplicatedObject::OnReceiveCreationRequest PlayerID  sender,
RakNet::BitStream inContext,
RakNet::BitStream outContext,
PlayerID objectOwner,
DataReplicator dataReplicator
[virtual]
 

A remote system has asked that an instance of this class be created.To accept, return true. You will probably want to synchronize this class as well [Default does this already]

Parameters:
[in] sender The remote system
[in] inContext Data passed by the sender
[in] outContext Data to return to the sender
[in] objectOwner [OutParam] Which system owns the object, assuming it is created. If you don't set this it defaults to this system
[in] dataReplicator The instance of the DataReplicator class this object was synchronized with.
Returns:
true to accept creation of this class, false to delete it.

bool ReplicatedObject::OnReceiveReplicationPush PlayerID  sender,
RakNet::BitStream inContext,
ObjectID  newObjectId,
PlayerID objectOwner,
DataReplicator dataReplicator
[virtual]
 

The inverse of OnSendReplicationPush, the other system wants to send an object to us that we didn't request.

Parameters:
[in] sender The system that sent this object to us
[in] inContext What was passed to OnSendReplicationPush::outContext
[in] newObjectId The object ID to use for this new object.
[in] objectOwner [OutParam] Which system owns the object, assuming it is created. If you don't set this it defaults to this system
[in] dataReplicator The instance of the DataReplicator class this object was synchronized with.
Returns:
true to accept the object, false to tell the caller not to push the object to us and to delete it.

void ReplicatedObject::OnRemoteDereplication DataReplicator dataReplicator  )  [virtual]
 

Function called every time the object is dereplicated by remote systems that send those objects.

Parameters:
[in] dataReplicator The instance of the DataReplicator class this object was synchronized with.

void ReplicatedObject::OnScopeChange PlayerID  sender,
bool  isNowInScope,
DataReplicator dataReplicator
[virtual]
 

This object is either now in or now out of scope in relation to the system designated by playerId

Parameters:
[in] sender The remote system
[in] isNowInScope isNowInScope==true means that the InScope call returns true for your system, while false means it returns false.
[in] dataReplicator The instance of the DataReplicator class this object was synchronized with.

ObjectReplicationPushResult ReplicatedObject::OnSendCreationRequest PlayerID  destination,
RakNet::BitStream outContext,
DataReplicator dataReplicator
[virtual]
 

Called when we need this object created on the authoritative system

Parameters:
[in] destination The system to send to
[in] outContext Contextual data to include with the packet. This bitstream will be passed first to SetClassFactory() callback, then to OnReceiveReplicationPush::inContext
[in] dataReplicator The instance of the DataReplicator class this object was synchronized with.
Returns:
OBJECT_REPLICATION_OK to send a serialized copy of ReplicatedObject to that system immediately.

OBJECT_REPLICATION_PUSH_LATER to delay send. OnSendReplicationPush will be called again the next Update assuming that the object is still in scope.

OBJECT_REPLICATION_NEVER_PUSH to permanently remove that system as a potential recipient of objectToReplicate

ObjectReplicationPushResult ReplicatedObject::OnSendReplicationPush PlayerID  destination,
RakNet::BitStream outContext,
DataReplicator dataReplicator
[virtual]
 

Called when we have this object synchronized and the destination system does not.

Parameters:
[in] destination The system to send to
[in] outContext Contextual data to include with the packet. This bitstream will be passed first to SetClassFactory() callback, then to OnReceiveReplicationPush::inContext
[in] dataReplicator The instance of the DataReplicator class this object was synchronized with.
Returns:
OBJECT_REPLICATION_OK to send a serialized copy of ReplicatedObject to that system immediately.

OBJECT_REPLICATION_PUSH_LATER to delay send. OnSendReplicationPush will be called again the next Update assuming that the object is still in scope.

OBJECT_REPLICATION_NEVER_PUSH to permanently remove that system as a potential recipient of objectToReplicate

void ReplicatedObject::SetOwner PlayerID  _owner  ) 
 

Sets the owner

Parameters:
[in] _owner Owner of the object. When this system disconnects, the objects gets unsynchronized


Member Data Documentation

PlayerID ReplicatedObject::owner [protected]
 

This is the system that owns a particular object, which means when that system disconnects, other instances of this object on remote systems will Get a call to OnRemoteDereplication


The documentation for this class was generated from the following files:
Generated on Mon Mar 20 20:32:57 2006 for RakNet by  doxygen 1.4.6-NO