-
Notifications
You must be signed in to change notification settings - Fork 0
/
cocoservicemanager.cpp
47 lines (37 loc) · 1.27 KB
/
cocoservicemanager.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "cocoservicemanager.h"
CocoServiceManager::CocoServiceManager()
{
}
bool CocoServiceManager::startServer()
{
rpcServer.addService(new CocoService);
if (!rpcServer.listen(QHostAddress::LocalHost, 8118)) {
qDebug() << "can't start tcp server: " << rpcServer.errorString();
this->serverIsRunning = false;
//return -1;
}else{
qDebug() << "started server: " << rpcServer.serverAddress() << " " << rpcServer.serverPort();
this->serverIsRunning = true;
}
return this->serverIsRunning;
}
bool CocoServiceManager::sendTest()
{
QJsonRpcHttpClient client;
client.setEndPoint("http://127.0.0.1:9090");
QJsonArray test;
test.append(QJsonValue("MIMU"));
test.append(QJsonValue("MIMI"));
test.append(QJsonValue("SISI"));
QJsonObject test2;
test2["wew"] = "SISI";
// QJsonRpcMessage request = QJsonRpcMessage::createRequest("coco.testMethodWithParamsAndReturnValue", test2);
QJsonRpcMessage request = QJsonRpcMessage::createRequest("coco.testMethodWithParamsAndReturnValue", QJsonValue("MIMU"));
QJsonRpcMessage response = client.sendMessageBlocking(request);
qDebug() << request.toJson();
qDebug() << response.toJson();
}
bool CocoServiceManager::stopServer()
{
return false;
}