Files
ylib/include/net/http_server.h
2024-05-29 00:00:47 +08:00

88 lines
3.2 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#pragma once
#include "http_define.h"
#if USE_NET_HTTP_WEBSITE
#include <string>
#include <vector>
#include <map>
#include <functional>
#include <map>
#include "http_interface.h"
#include "qps.hpp"
namespace ylib
{
namespace network
{
namespace http
{
class http_server_lst;
class host;
/*************************************************************************
* classHTTP服务器
*************************************************************************/
class server :public ylib::error_base, public network::http::interface_
{
public:
server();
~server();
bool create(bool https, ushort port);
/******************************************************************
* Function启动
* Param
* ipaddress 监听地址
* port 监听端口
******************************************************************/
bool start();
/******************************************************************
* Function关闭
******************************************************************/
bool close();
/******************************************************************
* Function取远程信息
* Param
* connid 连接ID
* ipaddress 远程地址
* port 远程端口
******************************************************************/
bool remote(uint64 connid, std::string& ipaddress, ushort& port);
/******************************************************************
* FunctionHP服务指针
******************************************************************/
void* hpserver();
/******************************************************************
* Function每秒请求数
******************************************************************/
network::qps* qps();
inline const ushort port() { return m_port; }
#if USE_NET_HTTP_AGENT == 1
inline network::http::agent* agent() { return m_agent; }
#endif
public:
bool m_init_ssl;
private:
friend class http_server_lst;
private:
// HP HttpServer 指针
void* m_server;
// HP Listener 指针
network::http::http_server_lst* m_listener;
// https
bool m_https;
// 端口
ushort m_port;
// QPS
network::qps m_qps;
#if USE_NET_HTTP_AGENT == 1
// 代理指针
network::http::agent* m_agent;
#endif
};
}
}
}
#endif