54 lines
1.5 KiB
C++
54 lines
1.5 KiB
C++
#ifndef __APPLICATION_H__
|
|
#define __APPLICATION_H__
|
|
|
|
#include "Router/matches.hpp"
|
|
#include <boost/asio/io_context.hpp>
|
|
#include <boost/beast/http/string_body.hpp>
|
|
#include <memory>
|
|
|
|
namespace Core {
|
|
class IoContext;
|
|
class MessageManager;
|
|
} // namespace Core
|
|
|
|
namespace WeChat {
|
|
namespace Corporation {
|
|
class Context;
|
|
}
|
|
} // namespace WeChat
|
|
|
|
namespace Older {
|
|
|
|
class Settings;
|
|
class ApplicationPrivate;
|
|
class HttpSession;
|
|
class Database;
|
|
class SessionStore;
|
|
class SignalServer;
|
|
|
|
class Application : public std::enable_shared_from_this<Application> {
|
|
public:
|
|
using Pointer = std::shared_ptr<Application>;
|
|
using Request = boost::beast::http::request<boost::beast::http::string_body>;
|
|
using RequestHandler = std::function<void(HttpSession &, const Request &, const boost::urls::matches &)>;
|
|
Application();
|
|
boost::asio::io_context &ioContext();
|
|
void startAcceptHttpConnections(const std::string &address, uint16_t port);
|
|
void insertUrl(std::string_view url, RequestHandler &&handler);
|
|
int exec();
|
|
|
|
protected:
|
|
void asyncAcceptHttpConnections();
|
|
|
|
private:
|
|
ApplicationPrivate *m_d = nullptr;
|
|
std::shared_ptr<Settings> m_settings;
|
|
std::shared_ptr<Core::IoContext> m_ioContext;
|
|
std::shared_ptr<Core::MessageManager> m_messageManager;
|
|
std::shared_ptr<SessionStore> m_sessionStore;
|
|
std::shared_ptr<Database> m_database;
|
|
std::shared_ptr<WeChat::Corporation::Context> m_corporationContext;
|
|
std::shared_ptr<SignalServer> m_signalServer;
|
|
};
|
|
} // namespace Older
|
|
#endif // __APPLICATION_H__
|