Skip to content
This repository has been archived by the owner on Sep 22, 2022. It is now read-only.

kdeyev/QJsonChannel

Repository files navigation

Overview

QJsonChannel is a Qt implementation of the JSON-RPC protocol, which mimics to the functionality provided by QtWebChannel. Like QtWebChannel, QJsonChannel is leveraging Qt's meta-object system for method invocation. But unlike QtWebChannel is utilizing the idea of uni-directional communication. The project was started as a try to build an analog of QtWebChannel more suitable for stateless services.

QtWebChannel QJsonChannel
RPC protocol Internal JSON-based JSON-RPC 2.0
Communication protocol bi-directional uni-directional
Stateless communication - +
Server->Client call + -
WebSocket support + +
HTTP support - +
Services list Internal representation JSON Schema Service Descriptor

Components

  • QJsonChannelCore - RPC layer based on top of Qt meta objects invocation
  • qjsonchannel.js - JavaScript layer over simple-jsonrpc-js which uses the JSON Schema Service Descriptor for building JS stubs on client side.
  • QJsonChannelEmbed - the library utilizes QtWebChannel internal transport for passing messages to QJsonChannel RPC layer
  • QJsonChannelBeast - the library utilizes Boost.Beast library for WebSocket and HTTP transport over QJsonChannel RPC layer
  • QJsonChannelTufao - the library utilizes Tufao library for WebSocket and HTTP transport over QJsonChannel RPC layer

Build

Build Tufao

  1. set BOOST_ROOT environment variable
  2. cd QJsonChannel
  3. mkdir build && cd mkdir
  4. cmake -DCMAKE_INSTALL_PREFIX:PATH=../install -G "Visual Studio 15 2017 Win64" ..
  5. cmake --build . --target install

Build QJsonChannel

  1. cd QJsonChannel
  2. mkdir build && cd mkdir
  3. cmake -G "Visual Studio 15 2017 Win64" ..
  4. cmake --build .
  5. (for installation) cmake --build . --target install
  6. (for VS debugging) devenv Project.sln

Examples

Server side

Client-side

Client-side examples tips

All of these tests can work with with Tufao QJsonChannel Server or Boost.Beast QJsonChannel Server.

Hybrid (Server + Client)

  • QtWebChannel Hybrid Application illustrates a hybrid approach of application building. The example includes the logic of both frontend and backend and uses QtWebChannel for the communication between JavaScript and C++.
  • QJsonChannel Hybrid Application illustrates the same idea as QtWebChannel Hybrid Application but uses QJsonChannel "instead of" QtWebChannel. Actually I have difficulties with the internal web channel transport access. So, currently I'm using the QtWebChannel for message passing, but the service invocation is done using QJsonChannel.

Hybrid Examples Tips

  1. For any QtWebChannel example may require Deploying Qt WebEngine Applications.
  2. Use Google Chrome http://localhost:9090 for debugging

Requirements

  • Qt 5.5 or greater
  • boost 1.67 or greater

References

  • QtWebChannel enables peer-to-peer communication between a server (QML/C++ application) and a client (HTML/JavaScript or QML application)
  • QJsonRpc is a Qt implementation of the JSON-RPC protocol.
  • Boost.Beast HTTP and WebSocket built on Boost.Asio in C++11
  • TUFÃO is an asynchronous web framework for C++ built on top of Qt
  • simple-jsonrpc-js - Simple JSON-RPC javascript library. Generate and parse json rpc messages
  • jsonrpc-requests - compact and simple JSON-RPC client implementation
  • JSON is a lightweight data interchange format.
  • JSON-RPC is lightweight remote procedure call protocol similar to XML-RPC.
  • React JSon Schema Form A React component for building Web forms from JSON Schema.
  • JSON Schema Service Descriptor is simply a JSON Schema with the additional definition for methods.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published