![]() |
FastEngine 0.9.4
A multiplayer oriented 2D engine made with Vulkan.
|
Class that represent the identity of a client. More...
#include <C_client.hpp>
Classes | |
struct | CryptInfo |
Public Member Functions | |
Client (Latency_ms CTOSLatency, Latency_ms STOCLatency) | |
Constructor with default latencies. | |
void | setCTOSLatency_ms (Latency_ms latency) |
Set the "Client To Server" latency. | |
void | setSTOCLatency_ms (Latency_ms latency) |
Set the "Server To Client" latency. | |
Latency_ms | getCTOSLatency_ms () const |
Get the "Client To Server" latency. | |
Latency_ms | getSTOCLatency_ms () const |
Get the "Server To Client" latency. | |
Latency_ms | getPing_ms () const |
Compute the ping. | |
void | setCorrectorTimestamp (Timestamp timestamp) |
Set the corrector timestamp. | |
std::optional< Timestamp > | getCorrectorTimestamp () const |
Get the corrector timestamp. | |
std::optional< Latency_ms > | getCorrectorLatency () const |
Compute the corrector latency. | |
void | resetLastPacketTimePoint () |
Reset the time point for limiting the packets sending frequency. | |
std::chrono::milliseconds | getLastPacketElapsedTime () const |
Get the delta time between the last sent packet and the current time. | |
Latency_ms | getLastPacketLatency () const |
void | clearPackets () |
Clear the packet queue. | |
void | pushPacket (TransmitPacketPtr pck) |
Add a Packet to the queue. | |
void | pushForcedFrontPacket (TransmitPacketPtr pck) |
TransmitPacketPtr | popPacket () |
Pop a packet from the queue. | |
bool | isPendingPacketsEmpty () const |
Check if the packet queue is empty. | |
void | disconnect (bool pushDisconnectPacket=true) |
ProtocolPacket::RealmType | getCurrentRealm () const |
std::chrono::milliseconds | getLastRealmChangeElapsedTime () const |
void | setCurrentRealm (ProtocolPacket::RealmType realm) |
ProtocolPacket::RealmType | advanceCurrentRealm () |
ProtocolPacket::CounterType | getCurrentPacketCounter () const |
ProtocolPacket::CounterType | advanceCurrentPacketCounter () |
void | setCurrentPacketCounter (ProtocolPacket::CounterType counter) |
ProtocolPacket::CounterType | getClientPacketCounter () const |
ProtocolPacket::CounterType | advanceClientPacketCounter () |
void | setClientPacketCounter (ProtocolPacket::CounterType counter) |
void | resetLastReorderedPacketCounter () |
ProtocolPacket::CounterType | getLastReorderedPacketCounter () const |
PacketReorderer & | getPacketReorderer () |
PacketReorderer const & | getPacketReorderer () const |
DataLockPair< PacketCache *, std::recursive_mutex > | getPacketCache () |
DataLockPair< PacketCache const *, std::recursive_mutex > | getPacketCache () const |
void | acknowledgeReception (ReceivedPacketPtr const &packet) |
std::vector< PacketCache::Label > const & | getAcknowledgedList () const |
void | clearAcknowledgedList () |
void | clearLostPacketCount () |
uint32_t | advanceLostPacketCount () |
void | setLostPacketThreshold (uint32_t threshold) |
uint32_t | getLostPacketThreshold () const |
uint32_t | getLostPacketCount () const |
ClientStatus const & | getStatus () const |
ClientStatus & | getStatus () |
CryptInfo const & | getCryptInfo () const |
CryptInfo & | getCryptInfo () |
uint16_t | getMTU () const |
void | setMTU (uint16_t mtu) |
void | setPacketReturnRate (std::chrono::milliseconds rate) |
std::chrono::milliseconds | getPacketReturnRate () const |
Static Public Member Functions | |
static Timestamp | getTimestamp_ms () |
Get a modulated timestamp of the current time. | |
static Timestamp | getTimestamp_ms (FullTimestamp fullTimestamp) |
static FullTimestamp | getFullTimestamp_ms () |
Get a timestamp of the current time. | |
static Latency_ms | computeLatency_ms (Timestamp const &sentTimestamp, Timestamp const &receivedTimestamp) |
Compute the latency for the client->server / server->client with the given timestamps. |
Public Attributes | |
CallbackHandler< Client & > | _onThresholdLostPacket |
Event | _event |
Optional client-side event that can be synchronized with the server. | |
PropertyList | _data |
Some user-defined client properties. | |
OneWayLatencyPlanner | _latencyPlanner |
A latency planner that will help latency calculation. | |
bool | _mtuFinalizedFlag {false} |
A flag that indicate if the MTU has been finalized from the remote side. |
Class that represent the identity of a client.
|
explicit |
Constructor with default latencies.
CTOSLatency | The "Client To Server" latency |
STOCLatency | The "Server To Client" latency |
void fge::net::Client::clearPackets | ( | ) |
Clear the packet queue.
|
static |
Compute the latency for the client->server / server->client with the given timestamps.
sentTimestamp | The timestamp that have been sent |
receivedTimestamp | The received timestamp |
std::optional< Latency_ms > fge::net::Client::getCorrectorLatency | ( | ) | const |
Compute the corrector latency.
The corrector latency is simply the time between the set timestamp and the timestamp now.
This is useful in order to compute more precise latency between client/server
std::optional< Timestamp > fge::net::Client::getCorrectorTimestamp | ( | ) | const |
Get the corrector timestamp.
When the getCorrectorLatency method is called, it will clear the corrector timestamp and std::nullopt will be returned.
Latency_ms fge::net::Client::getCTOSLatency_ms | ( | ) | const |
Get the "Client To Server" latency.
|
static |
Get a timestamp of the current time.
|
nodiscard |
Get the delta time between the last sent packet and the current time.
Latency_ms fge::net::Client::getPing_ms | ( | ) | const |
Compute the ping.
The ping is simply the CTOS + STOC latencies.
Latency_ms fge::net::Client::getSTOCLatency_ms | ( | ) | const |
Get the "Server To Client" latency.
|
static |
Get a modulated timestamp of the current time.
bool fge::net::Client::isPendingPacketsEmpty | ( | ) | const |
Check if the packet queue is empty.
TransmitPacketPtr fge::net::Client::popPacket | ( | ) |
Pop a packet from the queue.
void fge::net::Client::pushPacket | ( | TransmitPacketPtr | pck | ) |
Add a Packet to the queue.
The packet will be sent when the network thread is ready to send it. The network thread is ready to send a packet when the time interval between the last sent packet is greater than the latency of the server->client.
The current realm will be set and the current countId will be incremented and set to the packet.
pck | The packet to send with eventual options |
void fge::net::Client::resetLastPacketTimePoint | ( | ) |
Reset the time point for limiting the packets sending frequency.
This function is generally automatically called by the network thread.
void fge::net::Client::setCorrectorTimestamp | ( | Timestamp | timestamp | ) |
Set the corrector timestamp.
A corrector timestamp is generally set with the timestamp of a received packet.
timestamp | The corrector timestamp |
void fge::net::Client::setCTOSLatency_ms | ( | Latency_ms | latency | ) |
Set the "Client To Server" latency.
latency | Latency in milliseconds |
void fge::net::Client::setSTOCLatency_ms | ( | Latency_ms | latency | ) |
Set the "Server To Client" latency.
latency | Latency in milliseconds |
PropertyList fge::net::Client::_data |
Some user-defined client properties.
Event fge::net::Client::_event |
Optional client-side event that can be synchronized with the server.
OneWayLatencyPlanner fge::net::Client::_latencyPlanner |
A latency planner that will help latency calculation.
bool fge::net::Client::_mtuFinalizedFlag {false} |
A flag that indicate if the MTU has been finalized from the remote side.