forked from joncol/jcon-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_service.cpp
More file actions
35 lines (27 loc) · 1013 Bytes
/
example_service.cpp
File metadata and controls
35 lines (27 loc) · 1013 Bytes
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
#include "example_service.h"
#include <jcon/json_rpc_tcp_server.h>
#include <QDebug>
#include <QRandomGenerator>
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 QRandomGenerator::global()->generate() % 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;
}