23#include <sys/socket.h>
Class that represents a client that connects to a main server.
Definition: client.h:40
messageCallback m_messageCallback
Definition: client.h:54
std::atomic< bool > m_isConnected
Definition: client.h:57
std::queue< std::string > m_messageQueue
Definition: client.h:59
void receiverProcedure()
Thread procedure for caching/receiving incoming server data.
Definition: client.cc:38
~Client()
Destructs a Client object.
Definition: client.cc:154
struct sockaddr_in m_serverAddress
Definition: client.h:64
std::function< void(Client *client, std::string &)> messageCallback
The message callback function definition.
Definition: client.h:43
pthread_t m_receiverThreadId
Definition: client.h:49
int m_port
Definition: client.h:63
std::string m_host
Definition: client.h:62
bool isConnected() const
Get the connection status of the clienet.
Definition: client.cc:134
void sendMessage(const std::string &message)
Function wrapper to transmit a message.
Definition: client.cc:129
pthread_t m_processMessageThreadId
Definition: client.h:50
void connectServer()
Connect to the server.
Definition: client.cc:83
int m_clientSocket
Definition: client.h:61
connectCallback m_connectCallback
Definition: client.h:55
sem_t m_messageSemaphore
Definition: client.h:52
void disconnectServer()
Disconnect from the server.
Definition: client.cc:123
std::function< void(Client *client)> connectCallback
The connection callback function definition.
Definition: client.h:45
static constexpr size_t MAX_BUFFER_SIZE
Definition: client.h:47
pthread_mutex_t m_mutex
Definition: client.h:51
void processMessagesProcedure()
Thread procedure for processing cached/stored server data.
Definition: client.cc:19