mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-25 18:14:19 +01:00
libplugin: Add functions to start and end notifications
This commit is contained in:
committed by
Rusty Russell
parent
c1f08a42fe
commit
c8c0c4dc99
@@ -1032,6 +1032,25 @@ static void plugin_logv(struct plugin *p, enum log_level l,
|
||||
jsonrpc_finish_and_send(p, js);
|
||||
}
|
||||
|
||||
struct json_stream *plugin_notification_start(struct plugin *plugin,
|
||||
const char *method)
|
||||
{
|
||||
struct json_stream *js = new_json_stream(plugin, NULL, NULL);
|
||||
|
||||
json_object_start(js, NULL);
|
||||
json_add_string(js, "jsonrpc", "2.0");
|
||||
json_add_string(js, "method", method);
|
||||
|
||||
json_object_start(js, "params");
|
||||
return js;
|
||||
}
|
||||
void plugin_notification_end(struct plugin *plugin,
|
||||
struct json_stream *stream)
|
||||
{
|
||||
json_object_end(stream);
|
||||
jsonrpc_finish_and_send(plugin, stream);
|
||||
}
|
||||
|
||||
struct json_stream *plugin_notify_start(struct command *cmd, const char *method)
|
||||
{
|
||||
struct json_stream *js = new_json_stream(cmd, NULL, NULL);
|
||||
|
||||
@@ -246,6 +246,13 @@ void plugin_log(struct plugin *p, enum log_level l, const char *fmt, ...) PRINTF
|
||||
struct json_stream *plugin_notify_start(struct command *cmd, const char *method);
|
||||
void plugin_notify_end(struct command *cmd, struct json_stream *js);
|
||||
|
||||
/* Send a notification for a custom notification topic. These are sent
|
||||
* to lightningd and distributed to subscribing plugins. */
|
||||
struct json_stream *plugin_notification_start(struct plugin *plugins,
|
||||
const char *method);
|
||||
void plugin_notification_end(struct plugin *plugin,
|
||||
struct json_stream *stream TAKES);
|
||||
|
||||
/* Convenience wrapper for notify "message" */
|
||||
void plugin_notify_message(struct command *cmd,
|
||||
enum log_level level,
|
||||
|
||||
Reference in New Issue
Block a user