-
-
Notifications
You must be signed in to change notification settings - Fork 66
Expand file tree
/
Copy pathexample_service.cpp
More file actions
47 lines (37 loc) · 1.27 KB
/
example_service.cpp
File metadata and controls
47 lines (37 loc) · 1.27 KB
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 "example_service.h"
#include <jcon/json_rpc_tcp_server.h>
#include <QDebug>
#include <QtGlobal>
ExampleService::ExampleService() = default;
ExampleService::~ExampleService() = default;
int ExampleService::getRandomInt(int limit)
{
qDebug().noquote() << QString("-> getRandomInt: '%1' (client IP: %2)")
.arg(limit)
.arg(jcon::JsonRpcServer::clientEndpoint()->peerAddress().toString());
return qrand() % limit;
}
QString ExampleService::printMessage(const QString& msg)
{
qDebug().noquote() << QString("-> printMessage: '%1'").arg(msg);
return QString("Return: '%1'").arg(msg);
}
void ExampleService::printNotification(const QString &msg) {
qDebug().noquote() << QString("-> printNotification: '%1'").arg(msg);
}
void ExampleService::namedParams(QString& msg, int answer)
{
qDebug().noquote() << QString("-> namedParams");
qDebug().noquote() << " msg: " << msg;
qDebug().noquote() << " answer: " << answer;
}
jcon::JsonRpcFuture ExampleService::futureGetRandomInt(int limit)
{
qDebug().noquote() << QString("-> getRandomInt: '%1' (client IP: %2)")
.arg(limit)
.arg(jcon::JsonRpcServer::clientEndpoint()->peerAddress().toString());
return {[limit]{
QThread::sleep(5);
return qrand() % limit;
}};
}