// SPDX-FileCopyrightText: 2024 Yury Gubich // SPDX-License-Identifier: GPL-3.0-or-later #pragma once #include #include #include #include #include #include "shared/result.h" #include "actor.h" #include "logger.h" namespace Module { class Module; }; class Connection; class Router { public: Router(const Logger& logger); void registerModule(const std::string& key, const std::shared_ptr& module); void registerActor(const std::string& key, const std::string& group); void routeMessage(const std::string& sender, const std::string& body); std::map getActors() const; void setConnection(const std::shared_ptr& connection); void setResponses(Shared::Result result, const Shared::Strings& options); std::string getGroup(const std::string& key) const; private: void onMessageResult(Shared::Result result, const std::string& sender); private: typedef std::map> Modules; typedef std::map> Actors; typedef std::vector List; typedef std::map Responses; std::weak_ptr connection; const Logger& logger; Modules modules; Actors actors; std::string defaultGroup; Responses responses; std::mt19937 generator; };