From ba5a6374b691911e630351b50f3df739b159784d Mon Sep 17 00:00:00 2001 From: Přemysl Eric Janouch Date: Sun, 4 Sep 2022 15:21:14 +0200 Subject: json-rpc-test-server: add a "wait" method Considering the server's nature, the global lock-up it causes shouldn't constitute a major problem. --- json-rpc-test-server.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/json-rpc-test-server.c b/json-rpc-test-server.c index 801fb88..99842f5 100644 --- a/json-rpc-test-server.c +++ b/json-rpc-test-server.c @@ -1,7 +1,7 @@ /* * json-rpc-test-server.c: JSON-RPC 2.0 demo server * - * Copyright (c) 2015 - 2020, Přemysl Eric Janouch + * Copyright (c) 2015 - 2022, Přemysl Eric Janouch * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted. @@ -1464,7 +1464,7 @@ json_rpc_discover (struct server_context *ctx, json_t *params) json_t *info = json_pack ("{ssss}", "title", PROGRAM_NAME, "version", PROGRAM_VERSION); - json_t *methods = json_pack ("[ooo]", + json_t *methods = json_pack ("[oooo]", open_rpc_describe ("date", json_pack ("{ssso}", "type", "object", "properties", json_pack ("{s{ss}s{ss}s{ss}s{ss}s{ss}s{ss}}", "year", "type", "number", @@ -1475,7 +1475,8 @@ json_rpc_discover (struct server_context *ctx, json_t *params) "seconds", "type", "number"))), open_rpc_describe ("ping", json_pack ("{ss}", "type", "string")), open_rpc_describe ("rpc.discover", json_pack ("{ss}", "$ref", - "https://github.com/open-rpc/meta-schema/raw/master/schema.json"))); + "https://github.com/open-rpc/meta-schema/raw/master/schema.json")), + open_rpc_describe ("wait", json_pack ("{ss}", "type", "null"))); return json_rpc_response (NULL, json_pack ("{sssoso}", "openrpc", "1.2.6", "info", info, "methods", methods), NULL); } @@ -1492,6 +1493,16 @@ json_rpc_ping (struct server_context *ctx, json_t *params) return json_rpc_response (NULL, json_string ("pong"), NULL); } +static json_t * +json_rpc_wait (struct server_context *ctx, json_t *params) +{ + (void) ctx; + (void) params; + + sleep (1); + return json_rpc_response (NULL, json_null (), NULL); +} + static json_t * json_rpc_date (struct server_context *ctx, json_t *params) { @@ -1524,6 +1535,7 @@ process_json_rpc_request (struct server_context *ctx, json_t *request) { "date", json_rpc_date }, { "ping", json_rpc_ping }, { "rpc.discover", json_rpc_discover }, + { "wait", json_rpc_wait }, }; if (!json_is_object (request)) -- cgit v1.2.3-70-g09d2