/
Shymer123
/
LumenServer
Обзор
Документация
Войти
/
Shymer123
/
LumenServer
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
Server/SourceFiles/Core/Network/Router.h
40 строк
1 KB
Shymer123
Initial commit: LumenServer
20 июн 2026, 12:43
20 июн 2026, 12:43
173f14c
Код
Авторство
О чём код?
#ifndef ROUTER_H #define ROUTER_H #include "Core/Dependencies/ControllerDependencies.h" #include "TcpSession.h" namespace Core::Network { class ResponseContext; } namespace Core::Infrastructure { class TaskQueue; } namespace Core::Network { class Router { using JsonHandler = std::function<void(const nlohmann::json&, ResponseContext&)>; using FileHandler = std::function<void(const nlohmann::json&, const std::vector<std::byte>&, ResponseContext&)>; public: explicit Router(Infrastructure::TaskQueue& taskQueue); void registerJsonHandler(const std::string& command, JsonHandler handler); void registerFileHandler(const std::string& command, FileHandler handler); void routeJson(const std::vector<std::byte>& compressedJson, std::shared_ptr<TcpSession> session); void routeFile(const std::vector<std::byte>& compressedPayload, const std::vector<std::byte>& compressedRawData, std::shared_ptr<TcpSession> session); private: Infrastructure::TaskQueue& m_taskQueue; std::unordered_map<std::string, JsonHandler> m_jsonHandler; std::unordered_map<std::string, FileHandler> m_fileHandler; }; } // namespace Core::Network #endif // ROUTER_H