Patronum/Tests/defaultservice.cpp

36 lines
764 B
C++
Raw Normal View History

2020-05-06 23:23:46 +03:00
#include "defaultservice.h"
2020-05-18 18:28:15 +03:00
#include <QCoreApplication>
2020-05-06 23:23:46 +03:00
2020-05-07 16:08:56 +03:00
char* arg[] = {
const_cast<char*>("/"),
const_cast<char*>("exec")
2020-05-06 23:23:46 +03:00
};
2020-05-18 18:28:15 +03:00
int argc = 2;
2020-05-06 23:23:46 +03:00
DefaultService::DefaultService():
2020-05-07 16:08:56 +03:00
Patronum::Service<QCoreApplication>(2, arg, "TestPatronum") {
2020-05-18 18:28:15 +03:00
_core = new QCoreApplication(argc, arg);
2020-05-06 23:23:46 +03:00
}
void DefaultService::onStart() {
2020-05-06 23:23:46 +03:00
QuasarAppUtils::Params::log("Server started!", QuasarAppUtils::Info);
}
2021-03-26 17:20:17 +03:00
bool DefaultService::handleReceive(const Patronum::Feature &data) {
if (data.cmd() == "ping") {
sendResuylt("pong");
return true;
2020-05-06 23:23:46 +03:00
}
2021-03-26 17:20:17 +03:00
return false;
2020-05-06 23:23:46 +03:00
}
2021-03-26 17:20:17 +03:00
QSet<Patronum::Feature> DefaultService::supportedFeatures() {
QSet<Patronum::Feature> res;
2020-05-06 23:23:46 +03:00
res += Patronum::Feature("ping", {}, "test ping", "ping");
return res;
}