C-chat
client.h
Go to the documentation of this file.
1 
6 #ifndef C_CHAT_CLIENT_H
7 #define C_CHAT_CLIENT_H
8 
9 #include "../common/threads.h"
10 #include "../common/sockets.h"
11 #include "../common/constants.h"
12 
13 struct UploadData {
14  char* uploadFilename;
15  Thread uploadThread;
16 };
17 
18 struct DownloadData {
19  char* downloadBuffer;
20  long long downloadFileSize;
21  long long downloadedSize;
22  unsigned int downloadFileId;
23 };
24 
25 extern Socket clientSocket;
26 /* Upload */
27 extern struct UploadData uploadData[MAX_CONCURRENT_FILE_TRANSFER]; // TODO: Sync access
28 /* Download */
29 extern struct DownloadData downloadData[MAX_CONCURRENT_FILE_TRANSFER]; // TODO: Sync access
30 
31 
41 
46 
52 void commandHandler(const char* command);
53 
61 void setUsername(const char* username);
62 
63 #endif //C_CHAT_CLIENT_H
THREAD_ENTRY_POINT
#define THREAD_ENTRY_POINT
A macro to declare a function meant to be used as an entry point for a thread.
Definition: threads.h:29
Socket
Information of a socket.
Definition: sockets.h:19
UploadData
Definition: client.h:13
receiveMessages
void receiveMessages()
Receives messages from the server and display them to the client.
Thread
Represents a thread.
Definition: threads.h:44
setUsername
void setUsername(const char *username)
Notifies the server of username change.
Definition: client.c:165
sendMessage
THREAD_ENTRY_POINT sendMessage(void *data)
An entry point for a thread that gets user input and send it to server.
Definition: client.c:26
DownloadData
Definition: client.h:18
MAX_CONCURRENT_FILE_TRANSFER
#define MAX_CONCURRENT_FILE_TRANSFER
Maximum concurrent transfer of file allowed per client.
Definition: constants.h:42
commandHandler
void commandHandler(const char *command)
Handles the command represented by the given string.