Open 3D Engine Multiplayer Gem API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
Multiplayer::PropertyPublisher Class Reference

Private helper class for the EntityReplicator to serialize and track entity adds/updates/deletes. The EntityReplicator owns the actual sending of the records. This class tracks the acknowledgement state of all the published records so that it can aggregate and reserialize changes for any updates or deletes that occur before previous records have been acknowledged. This also tracks whether or not it has ever received an acknowledgement and stores it in IsRemoteReplicatorEstablished as a way to know if the receiver has created the replicated entity. More...

#include <PropertyPublisher.h>

Public Types

enum class  OwnsLifetime { True , False }
 

Public Member Functions

 PropertyPublisher (NetEntityRole remoteNetworkRole, OwnsLifetime ownsLifetime, AzNetworking::IConnection &connection)
 
void SetRebasing ()
 
void SetDeleting ()
 
bool IsDeleting () const
 Returns true if the entity should be deleted, false if not. It will return true whether or not the delete has been acknowledged.
 
bool IsDeleted () const
 Returns true only if the entity delete has been acknlowledged.
 
bool IsRemoteReplicatorEstablished () const
 
bool CacheDeletePacket (NetBindComponent *netBindComponent, bool wasMigrated)
 
EntityMigrationMessage GenerateMigrationPacket (NetBindComponent *netBindComponent)
 
void UpdatePendingRecord (NetBindComponent *netBindComponent)
 
bool RequiresSerialization ()
 Returns true if there are any changes pending to send, false if not.
 
bool PrepareSerialization (NetBindComponent *netBindComponent)
 
NetworkEntityUpdateMessage GenerateUpdatePacket (NetBindComponent *netBindComponent, bool wasMigrated)
 
void FinalizeSerialization (AzNetworking::PacketId sentId)
 

Detailed Description

Private helper class for the EntityReplicator to serialize and track entity adds/updates/deletes. The EntityReplicator owns the actual sending of the records. This class tracks the acknowledgement state of all the published records so that it can aggregate and reserialize changes for any updates or deletes that occur before previous records have been acknowledged. This also tracks whether or not it has ever received an acknowledgement and stores it in IsRemoteReplicatorEstablished as a way to know if the receiver has created the replicated entity.

Member Function Documentation

◆ CacheDeletePacket()

bool Multiplayer::PropertyPublisher::CacheDeletePacket ( NetBindComponent netBindComponent,
bool  wasMigrated 
)

Generate and cache a "delete" update packet for this entity. For deletes, the entity data will no longer be available by the time GenerateUpdatePacket() is called, so the update packet needs to get generated before the local entity delete is completed.

Returns
true if a delete packet was cached, false if it wasn't If the delete packet wasn't cached, it's typically because it is unnecessary, since the add was never sent.

◆ FinalizeSerialization()

void Multiplayer::PropertyPublisher::FinalizeSerialization ( AzNetworking::PacketId  sentId)

Track the given packet id so that we can continue to send any fields currently changed until this packet (or later) has been acknowledged.

◆ GenerateMigrationPacket()

EntityMigrationMessage Multiplayer::PropertyPublisher::GenerateMigrationPacket ( NetBindComponent netBindComponent)

Generate a migration packet for this entity. Unlike GenerateUpdatePacket, this method expects that you have not called PrepareSerialization first.

◆ GenerateUpdatePacket()

NetworkEntityUpdateMessage Multiplayer::PropertyPublisher::GenerateUpdatePacket ( NetBindComponent netBindComponent,
bool  wasMigrated 
)

Generate an add/update/delete packet for this entity. This method expects that UpdatePendingRecord and PrepareSerialization have been called prior to this.

◆ IsRemoteReplicatorEstablished()

bool Multiplayer::PropertyPublisher::IsRemoteReplicatorEstablished ( ) const

Returns true if the receiver has acknowledged at least one serialized record, which means that it exists and has created the entity and an entity replicator.

◆ PrepareSerialization()

bool Multiplayer::PropertyPublisher::PrepareSerialization ( NetBindComponent netBindComponent)

Based on the current publishing state, append an updated list of changed fields to the pending record and add it to the sentRecords list.

◆ SetDeleting()

void Multiplayer::PropertyPublisher::SetDeleting ( )

Set the publishing state to "deleting". The next record sent will be a delete record. Delete records will also send the final changed property states at the point of deletion.

◆ SetRebasing()

void Multiplayer::PropertyPublisher::SetRebasing ( )

Set the publishing state to "rebasing". The next record sent will be a rebase record. Rebase records send the full replication state for Autonomous entities minus the predictable properties. These can be useful for client migrations.

◆ UpdatePendingRecord()

void Multiplayer::PropertyPublisher::UpdatePendingRecord ( NetBindComponent netBindComponent)

Append an updated list of changed fields to the pending record. This can get called multiple times in a frame without harm, the changes will just keep accumulating.


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