1
0
mirror of https://github.com/falk-werner/webfuse-provider synced 2024-10-27 20:44:10 +00:00
falk-werner_webfuse-provider/lib/webfuse_provider/impl/jsonrpc/proxy.h

81 lines
1.9 KiB
C
Raw Normal View History

#ifndef WFP_JSONRPC_PROXY_H
#define WFP_JSONRPC_PROXY_H
#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
#ifdef __cplusplus
extern "C" {
#endif
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);
extern struct wfp_jsonrpc_proxy *
wfp_jsonrpc_proxy_create(
struct wfp_timer_manager * manager,
int timeout,
wfp_jsonrpc_send_fn * send,
void * user_data);
extern void wfp_jsonrpc_proxy_dispose(
struct wfp_jsonrpc_proxy * proxy);
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
//------------------------------------------------------------------------------
extern void wfp_jsonrpc_proxy_invoke(
struct wfp_jsonrpc_proxy * proxy,
wfp_jsonrpc_proxy_finished_fn * finished,
void * user_data,
char const * method_name,
char const * param_info,
...
);
extern void wfp_jsonrpc_proxy_notify(
struct wfp_jsonrpc_proxy * proxy,
char const * method_name,
char const * param_info,
...
);
extern void wfp_jsonrpc_proxy_onresult(
struct wfp_jsonrpc_proxy * proxy,
json_t * message);
#ifdef __cplusplus
}
#endif
#endif