msgba/include/msgba/client_connection_data.h

54 lines
1.6 KiB
C

#ifndef MS_CLIENT_CONNECTION_DATA
#define MS_CLIENT_CONNECTION_DATA
#include <stddef.h>
#include <stdbool.h>
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>
struct msCoreController;
struct msPacketSaveRequestData;
/**
* Struct representing everything needed while a connection is established.
*/
struct msClientConnectionData {
//! The number of this thread.
size_t numberOfThread;
//! Where to receive and send packets.
int clientFd;
//! The core controller
struct msCoreController *coreController;
//! Mutex to avoid send multiple packets at once.
pthread_mutex_t *mutexSendPacket;
//! Mutex to avoid to do multiple key operations at once.
pthread_mutex_t *mutexPressKey;
//! The last time we sent a frame.
struct timespec *lastFrameDate;
//! The array of pending msPacketSaveRequest
struct msPacketSaveRequestData **saveRequests;
//! The mutex to take saveRequests from the beggining.
pthread_mutex_t *mutexSaveRequests;
//! The number of save requests.
size_t saveRequestsLen;
//! The number of frame.
size_t numberFrame;
};
/**
* Creates a new msClientConnectionData.
*
* @param numberOfThread The unique identifier for this connection.
* @param clientFd The client fd from which receive/send messages.
*/
struct msClientConnectionData *
msClientConnectionDataNew(size_t numberOfThread, int clientFd);
/**
* Function to cleanup the session data.
* @param data A pointer to the pointer to msClientConnectionData.
*/
void
msClientConnectionDataDestroy(struct msClientConnectionData **data);
#endif