# RakNet::Connection_RM3 Class Reference

Each remote system is represented by Connection_RM3. Used to allocate Replica3 and track which instances have been allocated Important function: AllocReplica() - must be overridden to create an object given an identifier for that object, which you define for all objects in your game. More...

`#include <ReplicaManager3.h>`

List of all members.

## Public Member Functions

virtual Replica3 * | AllocReplica (RakNet::BitStream *allocationIdBitstream)=0
| Class factory to create a Replica3 instance, given a user-defined identifier Identifier is returned by Replica3::WriteAllocationID() for what type of class to create See Replica3::Dealloc for the corresponding destruction message.
virtual void | GetConstructedReplicas (DataStructures::Multilist< ML_ORDERED_LIST, LastSerializationResult *, Replica3 * > &objectsTheyDoHave)
| Get list of all replicas that are constructed for this connection.
bool | HasReplicaConstructed (RakNet::Replica3 *replica)
virtual void | OnAutoserializeInterval (PRO defaultSendParameters, ReplicaManager3 *rm3)
virtual void | SendSerialize (RakNet::Replica3 *replica, RakNet::BitStream *serializationData, RakNetTime timestamp, PRO sendParameters, RakPeerInterface *rakPeer, unsigned char worldId)
SystemAddress | GetSystemAddress (void) const
RakNetGUID | GetRakNetGUID (void) const
virtual void | SetConstructionByList (DataStructures::Multilist< ML_STACK, Replica3 * > objectsThatExist, ReplicaManager3 *replicaManager)

Destroy objects that no longer exist. Create objects that now exist. objectsThatExist is the entire list of objects that should exist. Given a list of objects, compare it against constructedReplicas. Objects in objectsThatExist, that are not in constructedReplicas, and that pass Replica3::QueryConstruction() be constructed. Objects not in objectsThatExist, that are in constructedReplicas, and that pass Replica3::SerializeDestruction() be destroyed. This can be more efficient than ReplicaManager3::SetAutoConstructByQuery.

bool | IsInitialDownload (void) const
| Before the first call to SendConstruction(), returns true. After, returns false.

## Detailed Description

Each remote system is represented by Connection_RM3. Used to allocate Replica3 and track which instances have been allocated Important function: AllocReplica() - must be overridden to create an object given an identifier for that object, which you define for all objects in your game.

## Member Function Documentation

virtual Replica3* RakNet::Connection_RM3::AllocReplica | ( | RakNet::BitStream * | allocationIdBitstream | ) | `[pure virtual]`

Class factory to create a Replica3 instance, given a user-defined identifier Identifier is returned by Replica3::WriteAllocationID() for what type of class to create See Replica3::Dealloc for the corresponding destruction message.

See also:
  Replica3::WriteAllocationID() Return 0 if unable to create the intended object. Sample implementation: {RakNet::RakString typeName; allocationIdBitstream->Read(typeName); if (typeName=="Soldier") return new Soldier; return 0;}

Parameters:

  `[in]` | allocationIdBitstream | user-defined bitstream uniquely identifying a game object type

void Connection_RM3::GetConstructedReplicas | ( | DataStructures::Multilist< ML_ORDERED_LIST, LastSerializationResult *, Replica3 * > & | objectsTheyDoHave | ) | `[virtual]`

Get list of all replicas that are constructed for this connection.

Parameters:

  `[out]` | objectsTheyDoHave | Destination list. Returned in sorted ascending order, sorted on the value of the Replica3 pointer.

RakNetGUID RakNet::Connection_RM3::GetRakNetGUID | ( | void |  | ) | const`[inline]`

Returns:
  Returns the RakNetGUID passed to the constructor of this object

SystemAddress RakNet::Connection_RM3::GetSystemAddress | ( | void |  | ) | const`[inline]`

Returns:
  The system address passed to the constructor of this object

bool Connection_RM3::HasReplicaConstructed | ( | RakNet::Replica3 * | replica | ) |

Returns true if we think this remote connection has this replica constructed

Parameters:

  `[in]` | replica3 | Which replica we are querying

Returns:
  True if constructed, false othewise

void Connection_RM3::OnAutoserializeInterval | ( | PRO | defaultSendParameters,
|  | ReplicaManager3 * | rm3 |
| ) |  |  | `[virtual]`

Called periodically when the autoserialize interval set by ReplicaManager3::SetAutoSerializeInterval() elapses Defaults to at least 30 milliseconds Override to take more complex actions when serializing objects, or call ReplicaManager3::SetAutoSerializeInterval(0) to disable this feature and serialize objects in your own way Default implementation is to call Connection_RM3::SendSerializeIfChanged() for each member of constructedReplicas

Parameters:

  `[in]` | defaultSendParameters | Send parameters to use for serialization
  `[in]` | rm3 | Calling plugin instance

void Connection_RM3::SendSerialize | ( | RakNet::Replica3 * | replica,
|  | RakNet::BitStream * | serializationData,
|  | RakNetTime | timestamp,
|  | PRO | sendParameters,
|  | RakPeerInterface * | rakPeer,
|  | unsigned char | worldId |
| ) |  |  | `[virtual]`

Sends over a serialization update for replica NetworkID::GetNetworkID() is written automatically, serializationData is the object data This is used internally - however, you can also call it manually to send a data update for a remote replica

Parameters:

  `[in]` | replica | Which replica to serialize
  `[in]` | serializationData | Serialized object data
  `[in]` | timestamp | 0 means no timestamp. Otherwise message is prepended with ID_TIMESTAMP
  `[in]` | sendParameters | Parameters on how to send
  `[in]` | rakPeer | Instance of RakPeerInterface to send on
  `[in]` | worldId | Which world, see ReplicaManager3::SetWorldID()

void Connection_RM3::SetConstructionByList | ( | DataStructures::Multilist< ML_STACK, Replica3 * > | objectsThatExist,
|  | ReplicaManager3 * | replicaManager |
| ) |  |  | `[virtual]`

Destroy objects that no longer exist. Create objects that now exist. objectsThatExist is the entire list of objects that should exist. Given a list of objects, compare it against constructedReplicas. Objects in objectsThatExist, that are not in constructedReplicas, and that pass Replica3::QueryConstruction() be constructed. Objects not in objectsThatExist, that are in constructedReplicas, and that pass Replica3::SerializeDestruction() be destroyed. This can be more efficient than ReplicaManager3::SetAutoConstructByQuery.

Note:
  Connection_RM3::SetConstructionByList and ReplicaManager3::SetAutoConstructByQuery are mutually exclusive. Do not use both at the same time.

  Does NOT check QueryConstruction(). It is assumed that the objectsThatExist list itself determines construction or destruction.

Parameters:

  `[in]` | objectsThatExist | Objects to check against
  `[in]` | replicaManager | ReplicaManager3 instance this connection is using

The documentation for this class was generated from the following files:

- C:/RakNet/Source/ReplicaManager3.h
- C:/RakNet/Source/ReplicaManager3.cpp