msgba/include/msgba/client_connection_data.h

45 lines
1.2 KiB
C
Raw Normal View History

2023-03-10 23:37:11 +01:00
#ifndef MS_CLIENT_CONNECTION_DATA
#define MS_CLIENT_CONNECTION_DATA
#include <stddef.h>
#include <stdbool.h>
#include <stdlib.h>
#include <unistd.h>
2023-03-25 15:21:27 +01:00
#include <pthread.h>
2023-03-10 23:37:11 +01:00
struct msCoreController;
/**
* Struct representing everything needed while a connection is established.
*/
struct msClientConnectionData {
2023-03-25 15:21:27 +01:00
//! The number of this thread.
2023-03-10 23:37:11 +01:00
size_t numberOfThread;
2023-03-25 15:21:27 +01:00
//! Where to receive and send packets.
2023-03-10 23:37:11 +01:00
int clientFd;
2023-03-25 15:21:27 +01:00
//! The core controller
2023-03-10 23:37:11 +01:00
struct msCoreController *coreController;
2023-03-25 15:21:27 +01:00
//! Mutex to avoid send multiple packets at once.
2023-03-13 00:06:19 +01:00
pthread_mutex_t *mutexSendPacket;
2023-03-25 15:21:27 +01:00
//! Mutex to avoid to do multiple key operations at once.
pthread_mutex_t *mutexPressKey;
//! The last time we sent a frame.
struct timespec *lastFrameDate;
2023-03-10 23:37:11 +01:00
};
/**
* 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);
2023-03-25 15:21:27 +01:00
/**
* Function to cleanup the session data.
* @param data A pointer to the pointer to msClientConnectionData.
*/
2023-03-10 23:37:11 +01:00
void
msClientConnectionDataDestroy(struct msClientConnectionData **data);
#endif