// 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 "shared/loggable.h" #include "shared/utils.h" #include "actor.h" namespace Module { class Module; }; class Connection; class Router : private Shared::Loggable { public: Router(const Shared::Logger& logger); void registerModule(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; std::string getDefaultGroup() 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; Modules modules; Actors actors; std::string defaultGroup; Responses responses; std::mt19937 generator; };