FastEngine 0.9.3
A multiplayer oriented 2D engine made with Vulkan.
Loading...
Searching...
No Matches
fge::net::OneWayLatencyPlanner Struct Reference

A helper class that measure latency between client/server. More...

#include <C_client.hpp>

Public Types

enum  Stats : uint8_t { HAVE_EXTERNAL_TIMESTAMP = 1 << 0 }
 

Public Member Functions

void pack (TransmissionPacketPtr &tPacket)
 Pack the required data by the planner to the client/server.
 
void unpack (FluxPacket *packet, Client &client)
 Unpack the data received by another client/server planner.
 
std::optional< FullTimestampOffsetgetClockOffset () const
 Retrieve the clock offset.
 
std::optional< Latency_msgetLatency () const
 Retrieve the latency.
 
std::optional< Latency_msgetOtherSideLatency () const
 Retrieve the other side latency.
 
std::optional< Latency_msgetRoundTripTime () const
 Retrieve the RTT (Round Trip Time)
 

Detailed Description

A helper class that measure latency between client/server.

This class is called "one-way latency" but it actually compute the Round Trip Time minus a latency corrector divided by 2.

Warning
When using this class, do not manually edit the corrector latency in the Client class.

Member Function Documentation

◆ getClockOffset()

std::optional< FullTimestampOffset > fge::net::OneWayLatencyPlanner::getClockOffset ( ) const
nodiscard

Retrieve the clock offset.

The clock offset represent the delta time between 2 computers clocks. It is useful in order to predicate some data.

Returns
Optionally a full timestamp offset

◆ getLatency()

std::optional< Latency_ms > fge::net::OneWayLatencyPlanner::getLatency ( ) const
nodiscard

Retrieve the latency.

Returns
Optionally a latency

◆ getOtherSideLatency()

std::optional< Latency_ms > fge::net::OneWayLatencyPlanner::getOtherSideLatency ( ) const
nodiscard

Retrieve the other side latency.

This is the latency computed at the other end (client or server)

Returns
Optionally a latency

◆ getRoundTripTime()

std::optional< Latency_ms > fge::net::OneWayLatencyPlanner::getRoundTripTime ( ) const
nodiscard

Retrieve the RTT (Round Trip Time)

CLIENT

FIRST_PACKET LAST_PACKET O O | |

  • -
    • -
      • -
        • -
          • -
            • - | | O -----— O RECEIVING PACKETS

SERVER

| | -----------------------> RTT (Round Trip Time) ms | | | | | | -------> Server To Client (STOC) time ms -------> Client To Server (CTOS) time ms | | -------------> Latency corrector computed by the server

Returns
Optionally a RTT in ms

◆ pack()

void fge::net::OneWayLatencyPlanner::pack ( TransmissionPacketPtr & tPacket)

Pack the required data by the planner to the client/server.

Parameters
tPacketA TransmissionPacket

◆ unpack()

void fge::net::OneWayLatencyPlanner::unpack ( FluxPacket * packet,
Client & client )

Unpack the data received by another client/server planner.

Parameters
packetA received packet
clientA client

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