30 lines
621 B
C++
30 lines
621 B
C++
#ifndef SRV_H
|
|
#define SRV_H
|
|
|
|
#include <iostream>
|
|
#include <string>
|
|
#include <vector>
|
|
#include <map>
|
|
#include <deque>
|
|
|
|
class Server {
|
|
public:
|
|
Server(int port, const std::vector<std::string>* questions, size_t n, const std::map<std::string, std::string>* templates);
|
|
void run();
|
|
|
|
private:
|
|
std::string getRandomQuestion();
|
|
void handleRequest(int client_socket);
|
|
void sendResponse(const std::string& response);
|
|
|
|
int port;
|
|
const std::vector<std::string>* questions;
|
|
size_t n;
|
|
std::deque<int> recentQuestions;
|
|
const std::map<std::string, std::string>* templates;
|
|
|
|
void sendAbout();
|
|
};
|
|
|
|
#endif // SRV_H
|
|
|