summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/taskmanager.cpp13
-rw-r--r--app/taskmanager.h2
2 files changed, 13 insertions, 2 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
diff --git a/app/taskmanager.h b/app/taskmanager.h
index 87ca4b2..8926639 100644
--- a/app/taskmanager.h
+++ b/app/taskmanager.h
@@ -35,7 +35,7 @@ signals:
private slots:
void query();
- void callService(const QString&, QJsonValue);
+ void callService(const QString& command, QJsonValue value);
void onConnected();
void onMessageReceived(std::shared_ptr<Message>);
void loadAvg();