1
This commit is contained in:
commit
bd58ea66de
10 changed files with 395 additions and 0 deletions
30
inc/srv.h
Normal file
30
inc/srv.h
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#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
|
||||
|
||||
10
inc/tplr.h
Normal file
10
inc/tplr.h
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
#ifndef TPLR_H
|
||||
#define TPLR_H
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
std::string renderTemplate(const std::string& templateContent, const std::map<std::string, std::string>& context);
|
||||
|
||||
#endif // TPLR_H
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue