2019-02-09 02:08:02 +00:00
|
|
|
#ifndef _WSFS_JSONRPC_SERVER_H
|
|
|
|
#define _WSFS_JSONRPC_SERVER_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>
|
|
|
|
#include "wsfs/jsonrpc/method.h"
|
2019-02-09 18:02:53 +00:00
|
|
|
#include "wsfs/time/timeout_manager.h"
|
|
|
|
#include "wsfs/time/timer.h"
|
|
|
|
|
2019-02-09 02:08:02 +00:00
|
|
|
|
|
|
|
struct wsfs_jsonrpc_request
|
|
|
|
{
|
|
|
|
bool is_pending;
|
|
|
|
wsfs_jsonrpc_method_finished_fn * finished;
|
|
|
|
void * user_data;
|
|
|
|
int id;
|
2019-02-09 18:02:53 +00:00
|
|
|
struct wsfs_timer timer;
|
2019-02-09 02:08:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct wsfs_jsonrpc_server
|
|
|
|
{
|
|
|
|
struct wsfs_jsonrpc_method * methods;
|
|
|
|
struct wsfs_jsonrpc_request request;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#endif
|
|
|
|
|
|
|
|
extern void wsfs_jsonrpc_server_init(
|
2019-02-09 18:02:53 +00:00
|
|
|
struct wsfs_jsonrpc_server * server,
|
|
|
|
struct wsfs_timeout_manager * manager);
|
2019-02-09 02:08:02 +00:00
|
|
|
|
|
|
|
extern void wsfs_jsonrpc_server_cleanup(
|
|
|
|
struct wsfs_jsonrpc_server * server);
|
|
|
|
|
|
|
|
extern void wsfs_jsonrpc_server_add(
|
|
|
|
struct wsfs_jsonrpc_server * server,
|
|
|
|
char const * name,
|
|
|
|
wsfs_jsonrpc_method_invoke_fn * invoke,
|
|
|
|
void * user_data );
|
|
|
|
|
|
|
|
extern void wsfs_jsonrpc_server_invoke(
|
|
|
|
struct wsfs_jsonrpc_server * server,
|
|
|
|
wsfs_jsonrpc_method_finished_fn * finished,
|
|
|
|
void * user_data,
|
2019-02-09 11:01:58 +00:00
|
|
|
char const * method_name,
|
|
|
|
char const * param_info,
|
|
|
|
...
|
|
|
|
);
|
|
|
|
|
|
|
|
extern void wsfs_jsonrpc_server_notify(
|
|
|
|
struct wsfs_jsonrpc_server * server,
|
|
|
|
char const * method_name,
|
2019-02-09 02:08:02 +00:00
|
|
|
char const * param_info,
|
|
|
|
...
|
|
|
|
);
|
|
|
|
|
|
|
|
extern void wsfs_jsonrpc_server_onresult(
|
|
|
|
struct wsfs_jsonrpc_server * server,
|
|
|
|
char const * message,
|
|
|
|
size_t length);
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|