VOX
A little voxel engine
|
The Client side interface with the network module. More...
#include <Client.hpp>
Classes | |
struct | sendInfo |
class | ServerDisconnected |
Public Types | |
enum | flags : uint8_t { ASYNC = 1 } |
Public Member Functions | |
Client (const std::string &ip, int port) | |
~Client () | |
Client (const Client &other)=delete | |
Client & | operator= (const Client &other)=delete |
Client (Client &&other)=delete | |
Client & | operator= (Client &&other)=delete |
void | runOnce (const int &timeout_ms=-1) |
void | send (const sendInfo &info) |
std::shared_ptr< IPacket > | popPacket () |
size_t | getQueueSize () const |
Public Attributes | |
std::unordered_map< uint64_t, std::chrono::time_point< std::chrono::high_resolution_clock > > | m_pings |
The Client side interface with the network module.
This class is responsible for managing the connection to the server and sending and receiving packets.
It is fully threadsafe and can be run in a separate thread.
About the sendInfo struct and the ASYNC flag:
if the client is running on another thread this flag can be usefull. when this flag is set the send function will only queue the packet to be sent. All of the serialization and the syscalls will be done in the client thread. If the packet being sent isnt highly delay sensitive this flag should be used. It wont change anything regarding performances if the client is running on the same thread as the sending thread.
About the ServerDisconnected exception:
It is the client's way of of notifying the user that the server disconnected.
the runOnce method will throw this exception if the server disconnected.
enum Client::flags : uint8_t |
Client::Client | ( | const std::string & | ip, |
int | port | ||
) |
Client::~Client | ( | ) |
|
delete |
|
delete |
size_t Client::getQueueSize | ( | ) | const |
std::shared_ptr< IPacket > Client::popPacket | ( | ) |
void Client::runOnce | ( | const int & | timeout_ms = -1 | ) |
void Client::send | ( | const sendInfo & | info | ) |
std::unordered_map<uint64_t, std::chrono::time_point<std::chrono::high_resolution_clock> > Client::m_pings |