![]() |
FastEngine 0.9.3
A multiplayer oriented 2D engine made with Vulkan.
|
Class that represent the identity of a client. More...
#include <C_client.hpp>
Public Member Functions | |
Client (Latency_ms CTOSLatency, Latency_ms STOCLatency) | |
Constructor with default latencies. | |
void | setSkey (Skey key) |
Set the session key for this client. | |
Skey | getSkey () const |
Get the session key for this client. | |
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. | |
Latency_ms | getLastPacketElapsedTime () const |
Get the delta time between the last sent packet and the current time. | |
void | clearPackets () |
Clear the packet queue. | |
void | pushPacket (TransmissionPacketPtr pck) |
Add a TransmissionPacket to the queue. | |
TransmissionPacketPtr | popPacket () |
Pop a packet from the queue. | |
bool | isPendingPacketsEmpty () const |
Check if the packet queue is empty. | |
ProtocolPacket::Realm | getCurrentRealm () const |
std::chrono::milliseconds | getLastRealmChangeElapsedTime () const |
void | setCurrentRealm (ProtocolPacket::Realm realm) |
ProtocolPacket::Realm | advanceCurrentRealm () |
ProtocolPacket::CountId | getCurrentPacketCountId () const |
ProtocolPacket::CountId | advanceCurrentPacketCountId () |
void | setCurrentPacketCountId (ProtocolPacket::CountId countId) |
ProtocolPacket::CountId | getClientPacketCountId () const |
ProtocolPacket::CountId | advanceClientPacketCountId () |
void | setClientPacketCountId (ProtocolPacket::CountId countId) |
PacketReorderer & | getPacketReorderer () |
PacketReorderer const & | getPacketReorderer () const |
void | clearLostPacketCount () |
uint32_t | advanceLostPacketCount () |
void | setLostPacketThreshold (uint32_t threshold) |
uint32_t | getLostPacketThreshold () const |
uint32_t | getLostPacketCount () const |
Static Public Member Functions | |
static Skey | GenerateSkey () |
Generate a new random session key. | |
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. | |
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 |
|
static |
Generate a new random session key.
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.
Latency_ms fge::net::Client::getLastPacketElapsedTime | ( | ) | const |
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.
Skey fge::net::Client::getSkey | ( | ) | const |
Get the session key for this client.
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.
TransmissionPacketPtr fge::net::Client::popPacket | ( | ) |
Pop a packet from the queue.
void fge::net::Client::pushPacket | ( | TransmissionPacketPtr | pck | ) |
Add a TransmissionPacket 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::setSkey | ( | Skey | key | ) |
Set the session key for this client.
key | The session key |
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.