| Top |
| void | (*JsonrpcServerHandler) () |
| JsonrpcServer * | jsonrpc_server_new () |
| void | jsonrpc_server_accept_io_stream () |
| guint | jsonrpc_server_add_handler () |
| void | jsonrpc_server_remove_handler () |
| void | jsonrpc_server_foreach () |
The JsonrpcServer class can help you implement a JSON-RPC server. You can accept connections and then communicate with clients using the JsonrpcClient API.
void (*JsonrpcServerHandler) (JsonrpcServer *self,JsonrpcClient *client,const gchar *method,GVariant *id,GVariant *params,gpointer user_data);
JsonrpcServer *
jsonrpc_server_new (void);
Creates a new JsonrpcServer.
Since: 3.26
void jsonrpc_server_accept_io_stream (JsonrpcServer *self,GIOStream *io_stream);
This function accepts io_stream
as a new client to the JsonrpcServer
by wrapping it in a JsonrpcClient and starting the message accept
loop.
Since: 3.26
guint jsonrpc_server_add_handler (JsonrpcServer *self,const gchar *method,JsonrpcServerHandler handler,gpointer handler_data,GDestroyNotify handler_data_destroy);
Adds a new handler that will be dispatched when a matching method
arrives.
self |
||
method |
A method to handle |
|
handler |
A handler to
execute when an incoming method matches |
[closure handler_data][destroy handler_data_destroy] |
handler_data |
user data for |
|
handler_data_destroy |
a destroy callback for |
Since: 3.26
void jsonrpc_server_remove_handler (JsonrpcServer *self,guint handler_id);
Removes a handler that was previously registered with jsonrpc_server_add_handler().
Since: 3.26
void jsonrpc_server_foreach (JsonrpcServer *self,GFunc foreach_func,gpointer user_data);
Calls foreach_func
for every client connected.
self |
||
foreach_func |
a callback for each client. |
[scope call] |
user_data |
closure data for |
Since: 3.28
struct JsonrpcServerClass {
GObjectClass parent_class;
gboolean (*handle_call) (JsonrpcServer *self,
JsonrpcClient *client,
const gchar *method,
GVariant *id,
GVariant *params);
void (*notification) (JsonrpcServer *self,
JsonrpcClient *client,
const gchar *method,
GVariant *params);
void (*client_accepted) (JsonrpcServer *self,
JsonrpcClient *client);
gpointer _reserved1;
gpointer _reserved2;
gpointer _reserved3;
gpointer _reserved4;
gpointer _reserved5;
gpointer _reserved6;
gpointer _reserved7;
};
“client-accepted” signalvoid user_function (JsonrpcServer *self, JsonrpcClient *client, gpointer user_data)
This signal is emitted when a new client has been accepted.
Flags: Run Last
Since: 3.28
“handle-call” signalgboolean user_function (JsonrpcServer *self, JsonrpcClient *client, gchar *method, GVariant *id, GVariant *params, gpointer user_data)
This method is emitted when the client requests a method call.
If you return TRUE from this function, you should reply to it (even upon
failure), using jsonrpc_client_reply() or jsonrpc_client_reply_async().
self |
||
client |
||
method |
the method that was called |
|
id |
the identifier of the method call |
|
params |
the parameters of the method call |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run Last
Since: 3.26
“notification” signalvoid user_function (JsonrpcServer *self, JsonrpcClient *client, gchar *method, GVariant *id, gpointer user_data)
This signal is emitted when the client has sent a notification to us.
self |
||
client |
||
method |
the notification name |
|
id |
the params for the notification |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run Last
Since: 3.26