-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver_session.h
43 lines (40 loc) · 1.14 KB
/
server_session.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "user.h"
#include<vector>
#include<queue>
#include<sys/socket.h>
#include<fcntl.h>
#include<arpa/inet.h>
#include<iostream>
#include<fstream>
#include<unistd.h>
#include<string.h>
#include<filesystem>
#define BACKLOG 4096
#define BUF_SIZE 1024
#define USER_DATA_PATH "./usermetadata.txt"
#define FILES_METADATA_PATH "./filemetadata.txt"
#define FILE_DIR_PATH "./files/"
class ServerSession {
int sockfd;
unordered_map<string, FileMetaData> filesMap;
unordered_map<string, User> users;
unordered_map<string, User> activeUsers;
pthread_mutex_t sessionLock;
pthread_cond_t sessionWait;
public:
ServerSession();
~ServerSession();
int getsockfd();
int loadFileMetaData();
int loadUserMetaData();
int startServer(int, struct sockaddr_in);
const char* authenticateUser(User, string);
void checkout(string, int, string);
void commit(string, int, string);
void deleteFile(string, int, string);
void addFile(string, int, string);
void quit(int, string);
string listall();
void printUsers();
void printFileMetaData();
};