2020-06-16 21:57:41 +00:00
|
|
|
#ifndef WFP_JSONRPC_PROXY_H
|
|
|
|
#define WFP_JSONRPC_PROXY_H
|
2020-02-28 22:17:41 +00:00
|
|
|
|
|
|
|
#ifndef __cplusplus
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#else
|
|
|
|
#include <cstdarg>
|
|
|
|
#include <cstddef>
|
|
|
|
using std::size_t;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <jansson.h>
|
2020-06-16 21:39:45 +00:00
|
|
|
#include "webfuse_provider/impl/jsonrpc/send_fn.h"
|
|
|
|
#include "webfuse_provider/impl/jsonrpc/proxy_finished_fn.h"
|
2020-02-29 01:32:03 +00:00
|
|
|
|
2020-02-28 22:17:41 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2020-06-16 21:57:41 +00:00
|
|
|
struct wfp_jsonrpc_proxy;
|
|
|
|
struct wfp_timer_manager;
|
2020-07-10 21:12:35 +00:00
|
|
|
struct wfp_json_writer;
|
|
|
|
|
|
|
|
typedef void
|
|
|
|
wfp_jsonrpc_custom_write_fn(
|
|
|
|
struct wfp_json_writer * writer,
|
|
|
|
void * data);
|
2020-02-28 22:17:41 +00:00
|
|
|
|
2020-06-16 21:57:41 +00:00
|
|
|
extern struct wfp_jsonrpc_proxy *
|
|
|
|
wfp_jsonrpc_proxy_create(
|
|
|
|
struct wfp_timer_manager * manager,
|
2020-02-28 22:17:41 +00:00
|
|
|
int timeout,
|
2020-06-16 21:57:41 +00:00
|
|
|
wfp_jsonrpc_send_fn * send,
|
2020-02-28 22:17:41 +00:00
|
|
|
void * user_data);
|
|
|
|
|
2020-06-16 21:57:41 +00:00
|
|
|
extern void wfp_jsonrpc_proxy_dispose(
|
|
|
|
struct wfp_jsonrpc_proxy * proxy);
|
2020-02-28 22:17:41 +00:00
|
|
|
|
2020-03-01 12:42:46 +00:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
/// \brief Invokes a method.
|
|
|
|
///
|
|
|
|
/// Creates a method an sends it using the send function.
|
|
|
|
/// Proxy keeps track of method invokation. If no response is returned within
|
|
|
|
/// timeout, an error is propagated.
|
|
|
|
///
|
|
|
|
/// \param proxy pointer to proxy instance
|
|
|
|
/// \param finished function which is called exactly once, either on success or
|
|
|
|
/// on failure.
|
|
|
|
/// \param method_name name of the method to invoke
|
|
|
|
/// \param param_info types of the param (s = string, i = integer, j = json)
|
|
|
|
/// \param ... params
|
|
|
|
//------------------------------------------------------------------------------
|
2020-06-16 21:57:41 +00:00
|
|
|
extern void wfp_jsonrpc_proxy_invoke(
|
|
|
|
struct wfp_jsonrpc_proxy * proxy,
|
|
|
|
wfp_jsonrpc_proxy_finished_fn * finished,
|
2020-02-28 22:17:41 +00:00
|
|
|
void * user_data,
|
|
|
|
char const * method_name,
|
|
|
|
char const * param_info,
|
|
|
|
...
|
|
|
|
);
|
|
|
|
|
2020-06-16 21:57:41 +00:00
|
|
|
extern void wfp_jsonrpc_proxy_notify(
|
|
|
|
struct wfp_jsonrpc_proxy * proxy,
|
2020-02-28 22:17:41 +00:00
|
|
|
char const * method_name,
|
|
|
|
char const * param_info,
|
|
|
|
...
|
|
|
|
);
|
|
|
|
|
2020-06-16 21:57:41 +00:00
|
|
|
extern void wfp_jsonrpc_proxy_onresult(
|
|
|
|
struct wfp_jsonrpc_proxy * proxy,
|
2020-02-28 22:17:41 +00:00
|
|
|
json_t * message);
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|