Client Interaction
Client plugins communicate with Controller Plugins using TCP/RPC frameworks or Rokae's built-in JSON communication protocol.

The client plugin sends a protocol message; the Controller Plugin receives and processes it.
This section describes communication using the built-in protocol.
#include "service/service_api.hpp"
/**
* @brief Plugin name, plugin key, callback function
* @note When the controller receives a JSON protocol message, it invokes the corresponding callback
* Protocol data received by the user is {"key":"value"}
*/
xcore_api::service::RegServiceAPI("example","get",
[](const Json::Value &in){
LOG_INFO<<"receive:"<<json_serialize(in);
// simu user process
std::this_thread::sleep_for(std::chrono::seconds(1));
Json::Value out;
out["return"] = "0";
return out;
});
The client plugin sends a protocol message with plugin name example and JSON data. The interface forwards the corresponding JSON data to the plugin.
JSON data received by plugin example:
{"key":" user json"}
JSON data returned to the client plugin:
{"key":" user return json"}

See examples/service.hpp for reference.