diff options
Diffstat (limited to 'src/plugins/relay/relay-remote.c')
-rw-r--r-- | src/plugins/relay/relay-remote.c | 73 |
1 files changed, 46 insertions, 27 deletions
diff --git a/src/plugins/relay/relay-remote.c b/src/plugins/relay/relay-remote.c index f7d9becb4..43c85d508 100644 --- a/src/plugins/relay/relay-remote.c +++ b/src/plugins/relay/relay-remote.c @@ -607,6 +607,25 @@ relay_remote_connect (struct t_relay_remote *remote) } /* + * Sends JSON data to a remote WeeChat relay/api. + * + * Returns: + * 1: OK + * 0: error + */ + +int +relay_remote_send (struct t_relay_remote *remote, const char *json) +{ + if (!remote || (remote->status != RELAY_STATUS_CONNECTED) || !json) + return 0; + + return (relay_remote_network_send (remote, RELAY_MSG_STANDARD, + json, strlen (json)) > 0) ? + 1 : 0; +} + +/* * Renames a remote. * * Returns: @@ -664,6 +683,33 @@ relay_remote_rename (struct t_relay_remote *remote, const char *name) } /* + * Disconnects one remote. + */ + +void +relay_remote_disconnect (struct t_relay_remote *remote) +{ + if (remote->sock >= 0) + relay_remote_network_disconnect (remote); +} + +/* + * Disconnects all remotes. + */ + +void +relay_remote_disconnect_all () +{ + struct t_relay_remote *ptr_remote; + + for (ptr_remote = relay_remotes; ptr_remote; + ptr_remote = ptr_remote->next_remote) + { + relay_remote_disconnect (ptr_remote); + } +} + +/* * Deletes a remote. */ @@ -716,33 +762,6 @@ relay_remote_free_all () } /* - * Disconnects one remote. - */ - -void -relay_remote_disconnect (struct t_relay_remote *remote) -{ - if (remote->sock >= 0) - relay_remote_network_disconnect (remote); -} - -/* - * Disconnects all remotes. - */ - -void -relay_remote_disconnect_all () -{ - struct t_relay_remote *ptr_remote; - - for (ptr_remote = relay_remotes; ptr_remote; - ptr_remote = ptr_remote->next_remote) - { - relay_remote_disconnect (ptr_remote); - } -} - -/* * Adds a remote in an infolist. * * If force_disconnected_state == 1, the infolist contains the remote |