~reykjalin/QJsonRpcClient

A json-rpc client implemented using Qt data types
Remove unnecessary line from cmakelists
Restructure project for better include semantics
Fix missing include in cmakelists

refs

master
browse  log 

clone

read-only
https://git.sr.ht/~reykjalin/QJsonRpcClient
read/write
git@git.sr.ht:~reykjalin/QJsonRpcClient

You can also use your local clone with git send-email.

#QJsonRpcClient

This is a client framework you can use for json-rpc v2.0 communications in your project using Qt data types.

The library makes use of the generic QIODevice for the communication, which means it should upport any generic communication protocol supported by Qt. See the QIODevice documentation for more details on protocols available.

#Dependencies

Only the Qt libraries.

#Example

#include <QString>
#include <QProcess>
#include <QStringList>
#include <QProcessEnvironment>
#include <QJsonValue>
#include <QJsonArray>

#include <memory>

#include <QJsonRpcClient/qjsonrpcclient.h>

// ...

auto process = std::make_unique<QProcess>();
p->setProcessEnvironment( QProcessEnvironment::systemEnvironment() );
p->setProgram( "/path/to/rpc-server" );
p->setArguments( { "server_arg_1", "server_arg_2" } );
if ( p->waitForStarted() ) {
	QJsonRpcClient rpcClient = std::make_unique<QJsonRpcClient>( std::move( p ) );
	
	int defaultResult = 0;
	QJsonValue result = rpcClient->callMethod( "add", QJsonArray{ 1, 2 } );
	std::cout << result.toInt( defaultResult ) << std::endl;
}