FastEngine 0.9.3
A multiplayer oriented 2D engine made with Vulkan.
Loading...
Searching...
No Matches
fge::NetworkTypeTasks Class Reference

Network type for the TaskHandler. More...

#include <C_task.hpp>

Inheritance diagram for fge::NetworkTypeTasks:
fge::net::NetworkTypeBase

Public Types

enum  SyncType : uint8_t { SYNC_CHECKSUM , SYNC_FULL }
 

Public Member Functions

 NetworkTypeTasks (fge::TaskHandler *source)
 
void const * getSource () const override
 Get the source pointer that have been used to create this network type.
 
bool applyData (fge::net::Packet const &pck) override
 Apply the data packed by the same network type from a server.
 
void packData (fge::net::Packet &pck, fge::net::Identity const &id) override
 Pack the data into a packet and reset the modification flag of the identity.
 
void packData (fge::net::Packet &pck) override
 Pack the data without any client identity.
 
bool check () const override
 Check if the value have been modified.
 
void forceCheck () override
 Force the value to be modified (even if it is not)
 
void forceUncheck () override
 Remove the forced modification of the value.
 
virtual bool clientsCheckup (fge::net::ClientList const &clients, bool force)
 Do a clients checkup with the specified client list.
 
virtual bool checkClient (fge::net::Identity const &id) const
 Check if the modification flag is set for the specified client identity.
 
virtual void forceCheckClient (fge::net::Identity const &id)
 Force the modification flag to be set for the specified client identity.
 
virtual void forceUncheckClient (fge::net::Identity const &id)
 Reset the modification flag for the specified client identity.
 
virtual void requireExplicitUpdateClient (fge::net::Identity const &id)
 Ask for an explicit update of the value for the specified client identity.
 
bool isForced () const
 Check if the value is forced to be modified.
 
void clearExplicitUpdateFlag ()
 
void needExplicitUpdate ()
 Tell that this network type need an explicit update from the server.
 
bool isNeedingExplicitUpdate () const
 
void clearWaitingUpdateFlag ()
 
void waitingUpdate ()
 Tell that this network type is waiting for an update.
 
bool isWaitingUpdate () const
 
std::chrono::microseconds getLastUpdateTime () const
 
void setLastUpdateTime ()
 

Public Attributes

fge::CallbackHandler _onApplied
 Callback called when the value have been applied.
 

Protected Member Functions

virtual void createClientCustomData (void *&ptr) const
 
virtual void destroyClientCustomData (void *&ptr) const
 
virtual void applyClientCustomData (void *&ptr) const
 

Protected Attributes

fge::net::NetworkPerClientModificationTable _g_tableId
 
bool _g_needExplicitUpdate {false}
 
bool _g_waitingUpdate {false}
 
bool _g_force {false}
 
std::chrono::microseconds _g_lastUpdateTime {0}
 

Detailed Description

Network type for the TaskHandler.

This class is used to synchronize the tasks of an object.

See also
TaskHandler

Member Function Documentation

◆ applyData()

bool fge::NetworkTypeTasks::applyData ( fge::net::Packet const & pck)
overridevirtual

Apply the data packed by the same network type from a server.

Parameters
pckThe packet containing the data
Returns
true if the data has been applied, false otherwise

Implements fge::net::NetworkTypeBase.

◆ check()

bool fge::NetworkTypeTasks::check ( ) const
overridevirtual

Check if the value have been modified.

Returns
true if the value have been modified, false otherwise

Implements fge::net::NetworkTypeBase.

◆ checkClient()

virtual bool fge::net::NetworkTypeBase::checkClient ( fge::net::Identity const & id) const
virtualinherited

Check if the modification flag is set for the specified client identity.

Parameters
idThe client identity to check
Returns
true if the modification flag is set, false otherwise

Reimplemented in fge::net::NetworkTypeScene.

◆ clientsCheckup()

virtual bool fge::net::NetworkTypeBase::clientsCheckup ( fge::net::ClientList const & clients,
bool force )
virtualinherited

Do a clients checkup with the specified client list.

The first step of the checkup is to add client in a table if they are not already in it and remove clients that are not in the list anymore.

Then the checkup check if the value have been modified and apply a modification flag to all clients.

Parameters
clientsThe client list to checkup with
forcetrue to force the checkup from the complete list of clients
Returns
true if there was a change in the value, false otherwise

Reimplemented in fge::net::NetworkTypeScene.

◆ forceCheck()

void fge::NetworkTypeTasks::forceCheck ( )
overridevirtual

Force the value to be modified (even if it is not)

Implements fge::net::NetworkTypeBase.

◆ forceCheckClient()

virtual void fge::net::NetworkTypeBase::forceCheckClient ( fge::net::Identity const & id)
virtualinherited

Force the modification flag to be set for the specified client identity.

Parameters
idThe client identity to force the modification flag for

Reimplemented in fge::net::NetworkTypeScene, and fge::net::NetworkTypeVector< T >.

◆ forceUncheck()

void fge::NetworkTypeTasks::forceUncheck ( )
overridevirtual

Remove the forced modification of the value.

Implements fge::net::NetworkTypeBase.

◆ forceUncheckClient()

virtual void fge::net::NetworkTypeBase::forceUncheckClient ( fge::net::Identity const & id)
virtualinherited

Reset the modification flag for the specified client identity.

Parameters
idThe client identity to reset the modification flag for

Reimplemented in fge::net::NetworkTypeScene, and fge::net::NetworkTypeVector< T >.

◆ getSource()

void const * fge::NetworkTypeTasks::getSource ( ) const
overridevirtual

Get the source pointer that have been used to create this network type.

Returns
A pointer to the source object

Implements fge::net::NetworkTypeBase.

◆ isForced()

bool fge::net::NetworkTypeBase::isForced ( ) const
nodiscardinherited

Check if the value is forced to be modified.

Returns
true if the value is forced to be modified, false otherwise

◆ needExplicitUpdate()

void fge::net::NetworkTypeBase::needExplicitUpdate ( )
inherited

Tell that this network type need an explicit update from the server.

◆ packData() [1/2]

void fge::NetworkTypeTasks::packData ( fge::net::Packet & pck)
overridevirtual

Pack the data without any client identity.

Parameters
pckThe packet to pack the data into

Implements fge::net::NetworkTypeBase.

◆ packData() [2/2]

void fge::NetworkTypeTasks::packData ( fge::net::Packet & pck,
fge::net::Identity const & id )
overridevirtual

Pack the data into a packet and reset the modification flag of the identity.

Parameters
pckThe packet to pack the data into
idThe identity of the client to pack the data for

Implements fge::net::NetworkTypeBase.

◆ requireExplicitUpdateClient()

virtual void fge::net::NetworkTypeBase::requireExplicitUpdateClient ( fge::net::Identity const & id)
virtualinherited

Ask for an explicit update of the value for the specified client identity.

A network type can discard the explicit update if it is not necessary or unimplemented.

Parameters
idThe client identity to ask for an explicit update

◆ waitingUpdate()

void fge::net::NetworkTypeBase::waitingUpdate ( )
inherited

Tell that this network type is waiting for an update.

When a network type is waiting for an update, it will wait for the next update to be applied until a certain delay (FGE_NET_WAITING_UPDATE_DELAY). After this delay, the network type will automatically request an explicit update.

When this method is called, the last update time is reset only if the network type is not already waiting.

See also
setLastUpdateTime()

Member Data Documentation

◆ _onApplied

fge::CallbackHandler fge::net::NetworkTypeBase::_onApplied
inherited

Callback called when the value have been applied.


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