First way to publish

This commit is contained in:
Blue 2025-03-28 23:12:34 +02:00
parent 0be7fe9bff
commit 647b8f3072
Signed by: blue
GPG key ID: 9B203B252A63EE38
17 changed files with 240 additions and 21 deletions

View file

@ -51,6 +51,16 @@ void Core::setGroup(const std::string& jid, const std::string& group) {
config.setActors(actors);
}
void Core::publish(const std::string& service, const std::string& node, const std::string& title, const std::string& body) {
std::shared_ptr<Connection> cn = connection.lock();
if (!cn) {
logger.log(Shared::Logger::warning, "Couldn't publish to " + node + "@" + service + ", connection is not available", {"Core"});
return;
}
cn->publish(service, node, title, body);
}
void Core::initializeActors() {
for (const std::pair<const std::string, std::string>& pair : config.getActors()) {
logger.log(Shared::Logger::info, "registering actor " + pair.first + " as " + pair.second, {"Core"});

View file

@ -19,6 +19,7 @@ public:
void send(const std::string& jid, const std::string& body);
void initialize(const std::shared_ptr<Connection>& connection);
void setGroup(const std::string& jid, const std::string& group);
void publish(const std::string& service, const std::string& node, const std::string& title, const std::string& body);
public:
Config config;

View file

@ -41,7 +41,7 @@ void Router::routeMessage(const std::string& sender, const std::string& body) {
if (aItr == actors.end())
aItr = actors.emplace(sender, std::make_shared<Actor>(sender, defaultGroup)).first;
std::vector<std::string> args = Module::Module::split(body);
Shared::Strings args = Shared::split(body);
std::string moduleAlias = Module::Module::lower(args[0]);
Modules::iterator mItr = modules.find(moduleAlias);

View file

@ -11,6 +11,7 @@
#include "shared/result.h"
#include "shared/loggable.h"
#include "shared/utils.h"
#include "actor.h"
namespace Module {