![]() |
FastEngine 0.9.4
A multiplayer oriented 2D engine made with Vulkan.
|
A special inheritance of Packet with a predefined communication protocol. More...
#include <C_protocol.hpp>
Classes | |
| struct | Header |
| struct | Option |
Public Types | |
| enum class | Options { UPDATE_TIMESTAMP , UPDATE_FULL_TIMESTAMP , UPDATE_CORRECTION_LATENCY } |
| Options to pass to the network thread when sending a packet. More... | |
| using | IdType = uint16_t |
| using | RealmType = uint16_t |
| using | CounterType = uint16_t |
Public Member Functions | |
| ProtocolPacket (Packet const &pck, Identity const &id, std::size_t fluxIndex=0, std::size_t fluxLifetime=0) | |
| ProtocolPacket (Packet &&pck, Identity const &id, std::size_t fluxIndex=0, std::size_t fluxLifetime=0) | |
| ProtocolPacket (IdType header, RealmType realmId=0, CounterType countId=0, CounterType lastCountId=0) | |
| ProtocolPacket (Packet const &r) | |
| ProtocolPacket (Packet &&r) noexcept | |
| ProtocolPacket (ProtocolPacket const &r) | |
| ProtocolPacket (ProtocolPacket &&r) noexcept | |
| Packet & | packet () noexcept |
| Packet const & | packet () const noexcept |
| bool | haveCorrectHeader () const |
| bool | haveCorrectHeaderSize () const |
| std::optional< IdType > | retrieveHeaderId () const |
| std::optional< IdType > | retrieveFlags () const |
| std::optional< IdType > | retrieveFullHeaderId () const |
| std::optional< RealmType > | retrieveRealm () const |
| std::optional< CounterType > | retrieveCounter () const |
| std::optional< CounterType > | retrieveLastCounter () const |
| std::optional< Header > | retrieveHeader () const |
| bool | isFragmented () const |
| ProtocolPacket & | setHeader (Header const &header) |
| ProtocolPacket & | setHeaderId (IdType id) |
| ProtocolPacket & | setFlags (IdType flags) |
| ProtocolPacket & | addFlags (IdType flags) |
| ProtocolPacket & | removeFlags (IdType flags) |
| bool | checkFlags (IdType flags) const |
| ProtocolPacket & | doNotDiscard () |
| ProtocolPacket & | doNotReorder () |
| ProtocolPacket & | doNotFragment () |
| ProtocolPacket & | setRealm (RealmType realm) |
| ProtocolPacket & | setCounter (CounterType counter) |
| ProtocolPacket & | setLastReorderedPacketCounter (CounterType counter) |
| void | setTimestamp (Timestamp timestamp) |
| Timestamp | getTimeStamp () const |
| Identity const & | getIdentity () const |
| std::vector< Option > const & | options () const |
| std::vector< Option > & | options () |
| bool | compress (Compressor &compressor) |
| bool | decompress (Compressor &compressor) |
| void | markForEncryption () |
| void | unmarkForEncryption () |
| bool | isMarkedForEncryption () const |
| void | markAsLocallyReordered () |
| void | unmarkAsLocallyReordered () |
| bool | isMarkedAsLocallyReordered () const |
| void | markAsCached () |
| void | unmarkAsCached () |
| bool | isMarkedAsCached () const |
| void | applyOptions (Client const &client) |
| Apply packet options to the packet. | |
| void | applyOptions () |
| Apply packet options to the packet. | |
| bool | checkFluxLifetime (std::size_t fluxSize) |
| Check if the flux lifetime is reached. | |
| std::size_t | getFluxIndex () const |
| std::size_t | bumpFluxIndex (std::size_t fluxSize) |
| std::vector< std::unique_ptr< ProtocolPacket > > | fragment (uint16_t mtu) const |
| void | clear () |
| void | flush () |
| void | reserve (std::size_t reserveSize) |
| Packet & | append (std::size_t size) |
| Packet & | append (void const *data, std::size_t size) |
| Packet & | pack (void const *data, std::size_t size) |
| bool | pack (std::size_t pos, void const *data, std::size_t size) |
| bool | write (std::size_t pos, void const *data, std::size_t size) |
| Packet const & | read (void *buff, std::size_t size) const |
| bool | read (std::size_t pos, void *buff, std::size_t size) const |
| Packet const & | unpack (void *buff, std::size_t size) const |
| bool | unpack (std::size_t pos, void *buff, std::size_t size) const |
| Packet & | shrink (std::size_t size) |
| bool | erase (std::size_t pos, std::size_t size) |
| Packet const & | skip (std::size_t size) const |
| void | setReadPos (std::size_t pos) const |
| std::size_t | getReadPos () const |
| bool | isExtractable (std::size_t size) const |
| uint8_t const * | getData (std::size_t pos) const |
| uint8_t * | getData (std::size_t pos) |
| uint8_t const * | getData () const |
| uint8_t * | getData () |
| std::size_t | getDataSize () const |
| uint32_t | getLength () const |
| void | invalidate () const |
| void | setValidity (bool validity) const |
| bool | isValid () const |
| operator bool () const | |
| bool | endReached () const |
| std::vector< uint8_t > const & | getTransmitCache () const |
| std::size_t | getTransmitPos () const |
| bool | isTransmitCacheValid () const |
| void | invalidateTransmitCache () |
| Packet & | operator<< (bool data) |
| Packet & | operator<< (int8_t data) |
| Packet & | operator<< (int16_t data) |
| Packet & | operator<< (int32_t data) |
| Packet & | operator<< (int64_t data) |
| Packet & | operator<< (uint8_t data) |
| Packet & | operator<< (uint16_t data) |
| Packet & | operator<< (uint32_t data) |
| Packet & | operator<< (uint64_t data) |
| Packet & | operator<< (float data) |
| Packet & | operator<< (double data) |
| Packet & | operator<< (long double data) |
| Packet & | operator<< (std::string_view const &data) |
| Packet & | operator<< (char const *data) |
| Packet & | operator<< (std::string const &data) |
| Packet & | operator<< (tiny_utf8::string const &data) |
| Packet & | operator<< (wchar_t const *data) |
| Packet & | operator<< (std::wstring const &data) |
| template<typename T> | |
| Packet & | operator<< (std::forward_list< T > const &data) |
| template<typename T> | |
| Packet & | operator<< (std::list< T > const &data) |
| template<typename T> | |
| Packet & | operator<< (std::vector< T > const &data) |
| template<typename T> | |
| Packet & | operator<< (fge::Vector2< T > const &data) |
| template<typename T> | |
| Packet & | operator<< (fge::Vector3< T > const &data) |
| template<typename T> | |
| Packet & | operator<< (fge::Matrix< T > const &data) |
| Packet & | operator<< (fge::Color const &data) |
| template<class TEnum, typename = std::enable_if_t<std::is_enum_v<TEnum>>> | |
| Packet & | operator<< (TEnum const &data) |
| template<class TData> | |
| Packet & | operator<< (std::unique_ptr< TData > const &data) |
| template<typename T> | |
| fge::net::Packet & | operator<< (std::forward_list< T > const &data) |
| template<typename T> | |
| fge::net::Packet & | operator<< (std::list< T > const &data) |
| template<typename T> | |
| fge::net::Packet & | operator<< (std::vector< T > const &data) |
| template<typename T> | |
| fge::net::Packet & | operator<< (fge::Vector2< T > const &data) |
| template<typename T> | |
| fge::net::Packet & | operator<< (fge::Vector3< T > const &data) |
| template<typename T> | |
| fge::net::Packet & | operator<< (fge::Matrix< T > const &data) |
| template<class TEnum, typename> | |
| fge::net::Packet & | operator<< (TEnum const &data) |
| template<class TData> | |
| fge::net::Packet & | operator<< (std::unique_ptr< TData > const &data) |
| Packet const & | operator>> (bool &data) const |
| Packet const & | operator>> (int8_t &data) const |
| Packet const & | operator>> (int16_t &data) const |
| Packet const & | operator>> (int32_t &data) const |
| Packet const & | operator>> (int64_t &data) const |
| Packet const & | operator>> (uint8_t &data) const |
| Packet const & | operator>> (uint16_t &data) const |
| Packet const & | operator>> (uint32_t &data) const |
| Packet const & | operator>> (uint64_t &data) const |
| Packet const & | operator>> (float &data) const |
| Packet const & | operator>> (double &data) const |
| Packet const & | operator>> (long double &data) const |
| Packet const & | operator>> (char *data) const |
| Packet const & | operator>> (std::string &data) const |
| Packet const & | operator>> (tiny_utf8::string &data) const |
| Packet const & | operator>> (wchar_t *data) const |
| Packet const & | operator>> (std::wstring &data) const |
| template<typename T> | |
| Packet const & | operator>> (std::forward_list< T > &data) const |
| template<typename T> | |
| Packet const & | operator>> (std::list< T > &data) const |
| template<typename T> | |
| Packet const & | operator>> (std::vector< T > &data) const |
| template<typename T> | |
| Packet const & | operator>> (fge::Vector2< T > &data) const |
| template<typename T> | |
| Packet const & | operator>> (fge::Vector3< T > &data) const |
| template<typename T> | |
| Packet const & | operator>> (fge::Matrix< T > &data) const |
| Packet const & | operator>> (fge::Color &data) const |
| template<class TEnum, typename = std::enable_if_t<std::is_enum_v<TEnum>>> | |
| Packet const & | operator>> (TEnum &data) const |
| template<class TData> | |
| Packet const & | operator>> (std::unique_ptr< TData > &data) const |
| template<typename T> | |
| fge::net::Packet const & | operator>> (std::forward_list< T > &data) const |
| template<typename T> | |
| fge::net::Packet const & | operator>> (std::list< T > &data) const |
| template<typename T> | |
| fge::net::Packet const & | operator>> (std::vector< T > &data) const |
| template<typename T> | |
| fge::net::Packet const & | operator>> (fge::Vector2< T > &data) const |
| template<typename T> | |
| fge::net::Packet const & | operator>> (fge::Vector3< T > &data) const |
| template<typename T> | |
| fge::net::Packet const & | operator>> (fge::Matrix< T > &data) const |
| template<class TEnum, typename> | |
| fge::net::Packet const & | operator>> (TEnum &data) const |
| template<class TData> | |
| fge::net::Packet const & | operator>> (std::unique_ptr< TData > &data) const |
| bool | operator== (Packet const &right) const =delete |
| bool | operator!= (Packet const &right) const =delete |
| virtual bool | onSend (std::size_t offset) |
| virtual void | onReceive (std::span< uint8_t const > const &data) |
Protected Attributes | |
| std::vector< uint8_t > | _g_transmitCache |
| std::size_t | _g_transmitPos |
| bool | _g_transmitCacheValid |
A special inheritance of Packet with a predefined communication protocol.
This class is used to handle the communication between the server and the client by storing a packet with its identity and timestamp. This also add some data used internally by the server in order to handle multiple received packets.
When transmitting a packet, the server will apply some options to the packet when sending it.
|
strong |
Options to pass to the network thread when sending a packet.
| Enumerator | |
|---|---|
| UPDATE_TIMESTAMP | The timestamp of the packet will be updated when sending. |
| UPDATE_FULL_TIMESTAMP | The full timestamp of the packet will be updated when sending. |
| UPDATE_CORRECTION_LATENCY | The latency of the packet will be updated with the corrector latency from the Client. |
| void fge::net::ProtocolPacket::applyOptions | ( | ) |
Apply packet options to the packet.
Same as applyOptions(Client const& client) but without the client parameter. UPDATE_CORRECTION_LATENCY will throw.
| void fge::net::ProtocolPacket::applyOptions | ( | Client const & | client | ) |
Apply packet options to the packet.
| client | The client to apply the options |
|
inlinenodiscard |
Check if the flux lifetime is reached.
Increment the flux lifetime and return false if the lifetime is greater or equal to fluxSize. Otherwise, increment the flux index and return true. The flux index is incremented by 1 and modulo fluxSize.
| fluxSize | The number of fluxes |