Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gustavosbarreto/libjsonrpcwebsocketserver
Qt JSON-RPC library over WebSocket
https://github.com/gustavosbarreto/libjsonrpcwebsocketserver
Last synced: 7 days ago
JSON representation
Qt JSON-RPC library over WebSocket
- Host: GitHub
- URL: https://github.com/gustavosbarreto/libjsonrpcwebsocketserver
- Owner: gustavosbarreto
- Created: 2014-11-08T02:51:54.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2015-04-09T20:45:41.000Z (over 9 years ago)
- Last Synced: 2024-10-28T20:12:24.201Z (about 2 months ago)
- Language: C++
- Homepage:
- Size: 180 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# libjsonrpcwebsocketserver
Bidirectional Qt JSON-RPC library over WebSocket# Installing
You obviously need Qt5 to build the library. There are two ways to install the library, see as follow:
## Installing into system
You can install the library into your linux system running the following:
```shell
qmake PREFIX=/usr
make
make install
```If you are using a qmake project add to your project file:
```
CONFIG += link_pkgconfig
PKGCONFIG += libjsonrpcwebsocketserver
```## Embedding into your project
To embed the library into your project without installing into the system, add the following to your qmake project file:
```
include(path/to/libjsonrpcwebsocketserver.pri)
```# API
## JsonRPCWebSocketServer
### call(interface, method, args, callback)
Call a remote method.
Parameter | Type | Description
--------- | ------------------ | -----------
interface | QString | Interface name
method | QString | Method name
callback | function(QVariant) | callback to be used to handle the responseExample:
```c++
JsonRPCWebSocketServer rpc;
rpc.connect("ws://localhost:80");
rpc.call("TestInterface", "testMethod", [] (QVariant result) {
// result is the value returned by the remote method
});
```### registerInterface(name, interface)
Register an interface in remote server.
Parameter | Type | Description
--------- | --------- | -----------
name | QString | Interface name
interface | QObject * | QObject instanceExample:
```c++
class MyInterface: public QObject
{
Q_OBJECTpublic slots:
int myMethod(x, y)
{
return x + y;
}
};MyInterface *myInterface = new MyInterface();
JsonRPCWebSocketServer rpc;
rpc.connect("ws://localhost:80");
rpc.registerInterface("MyInterface", myInterface);
```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/gustavosbarreto/libjsonrpcwebsocketserver/trend.png)](https://bitdeli.com/free "Bitdeli Badge")