-
Notifications
You must be signed in to change notification settings - Fork 0
/
MyHandle.h
61 lines (53 loc) · 1.48 KB
/
MyHandle.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//
// Created by Administrator on 2020/3/6.
//
#ifndef CPP_TCP_DEMO_MYHANDLE_H
#define CPP_TCP_DEMO_MYHANDLE_H
#include <list>
#include <mutex>
#include <map>
#include "Handler.h"
#include "RWLock.hpp"
#include <thread>
#include "libs/my_socket.h"
#include <cstdio>
#include <unistd.h>
#include <cstring>
#include <iostream>
#include "./libs/http/HttpServer.h"
using namespace std;
#define MAXLINE 4096
#define CLIENT_PORT 8528
#define HTTP_PORT 8529
struct ServerInfo{
ServerInfo(string _ip, int _proportion):ip(_ip), proportion(_proportion){}
string ip;
int proportion;
};
class MyHandle : public Handler {
public:
MyHandle(string username, string pwd);
~MyHandle();
void Server(int connfd, string remoteIp);
void HeartCheck(int);
void HeartCheckEntry();
void PreCheck();
bool DoCheck(const string &ip);
void DeleteAddr(string ip);
void HttpLogin(Request req, Response *resp);
void HttpAddServer(Request req, Response *resp);
void HttpDelServer(Request req, Response *resp);
void HttpGetAllServer(Request req, Response *resp);
void HttpChangeServer(Request req, Response *resp);
private:
typedef map<string, list<ServerInfo *> *> Server_map;
string http_username;
string http_pwd;
RWLock lock;
int heart_check_time;
HttpServer *http_server;
Server_map server_list_map;
};
bool count(const list<string> &l, string target);
bool count(const list<ServerInfo*> &l, string target);
#endif //CPP_TCP_DEMO_MYHANDLE_H