diff options
Diffstat (limited to 'app/taskmanager.cpp')
-rw-r--r-- | app/taskmanager.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/app/taskmanager.cpp b/app/taskmanager.cpp index f880b6b..97c376f 100644 --- a/app/taskmanager.cpp +++ b/app/taskmanager.cpp @@ -6,6 +6,8 @@ #include <iostream> #include <QtCore> #include <responsemessage.h> +#include <callmessage.h> +#include <messagefactory.h> #include "taskmanager.h" TaskManager::TaskManager(QObject* parent) : QObject(parent), m_loop(nullptr) { @@ -19,6 +21,7 @@ void TaskManager::open(const QUrl &bindingAddress) { m_loop = new MessageEngine(bindingAddress); QObject::connect(m_loop, &MessageEngine::connected, this, &TaskManager::onConnected); + QObject::connect(m_loop, &MessageEngine::messageReceived, this, &TaskManager::onMessageReceived, Qt::QueuedConnection); } void TaskManager::onConnected() @@ -51,7 +54,14 @@ void TaskManager::query() { callService("get_netstat", QJsonValue()); } -void TaskManager::callService(const QString&, QJsonValue) { +void TaskManager::callService(const QString& command, QJsonValue value) { + std::unique_ptr<Message> message = MessageFactory::getInstance().createOutboundMessage(MessageId::Call); + if (!message) + return; + CallMessage* msg = static_cast<CallMessage*>(message.get()); + msg->createRequest("taskmanager", command, value); + qDebug() << "sending message " << msg->serialize(); + m_loop->sendMessage(std::move(message)); } void TaskManager::onMessageReceived(std::shared_ptr<Message> message) @@ -66,6 +76,7 @@ void TaskManager::onMessageReceived(std::shared_ptr<Message> message) void TaskManager::ProcessResponse(std::shared_ptr<Message> message) { std::shared_ptr<ResponseMessage> rmsg = std::static_pointer_cast<ResponseMessage>(message); + qDebug() << "got message "; QString msgType = rmsg->replyData()["msgType"].toString(); if (msgType.isNull()) return; // no type supplied, ignoring |