Delta Chat Core C Interface
Loading...
Searching...
No Matches
Public Member Functions | List of all members
dc_jsonrpc_instance_t Class Reference

Opaque object for using the json rpc api from the cffi bindings. More...

#include <deltachat.h>

Public Member Functions

char * dc_jsonrpc_blocking_call (dc_jsonrpc_instance_t *jsonrpc_instance, const char *input)
 Make a JSON-RPC call and return a response.
 
char * dc_jsonrpc_next_response (dc_jsonrpc_instance_t *jsonrpc_instance)
 Get the next json_rpc response, blocks until there is a new event, so call this in a loop from a thread.
 
void dc_jsonrpc_request (dc_jsonrpc_instance_t *jsonrpc_instance, const char *request)
 Makes an asynchronous jsonrpc request, returns immediately and once the result is ready it can be retrieved via dc_jsonrpc_next_response() the jsonrpc specification defines an invocation id that can then be used to match request and response.
 
void dc_jsonrpc_unref (dc_jsonrpc_instance_t *jsonrpc_instance)
 Free a jsonrpc instance.
 

Detailed Description

Opaque object for using the json rpc api from the cffi bindings.

Member Function Documentation

◆ dc_jsonrpc_blocking_call()

char * dc_jsonrpc_blocking_call ( dc_jsonrpc_instance_t * jsonrpc_instance,
const char * input )

Make a JSON-RPC call and return a response.

See dc_jsonrpc_request() for an overview of possible calls and for more information.

Parameters
jsonrpc_instancejsonrpc instance as returned from dc_jsonrpc_init().
inputJSON-RPC request.
Returns
JSON-RPC response as string, must be freed using dc_str_unref() after usage. If there is no response, NULL is returned.

◆ dc_jsonrpc_next_response()

char * dc_jsonrpc_next_response ( dc_jsonrpc_instance_t * jsonrpc_instance)

Get the next json_rpc response, blocks until there is a new event, so call this in a loop from a thread.

Parameters
jsonrpc_instancejsonrpc instance as returned from dc_jsonrpc_init().
Returns
JSON-RPC response as string, must be freed using dc_str_unref() after usage. If NULL is returned, the accounts_t belonging to the jsonrpc instance is unref'd and no more events will come; in this case, free the jsonrpc instance using dc_jsonrpc_unref().

◆ dc_jsonrpc_request()

void dc_jsonrpc_request ( dc_jsonrpc_instance_t * jsonrpc_instance,
const char * request )

Makes an asynchronous jsonrpc request, returns immediately and once the result is ready it can be retrieved via dc_jsonrpc_next_response() the jsonrpc specification defines an invocation id that can then be used to match request and response.

An overview of JSON-RPC calls is available at https://js.jsonrpc.delta.chat/classes/RawClient.html. Note that the page describes only the rough methods. Calling convention, casing etc. does vary, this is a known flaw, and at some point we will get to improve that :)

Also, note that most calls are more high-level than this CFFI, require more database calls and are slower. They're more suitable for an environment that is totally async and/or cannot use CFFI, which might not be true for native apps.

Notable exceptions that exist only as JSON-RPC and probably never get a CFFI counterpart:

  • getMessageReactions(), sendReaction()
  • getHttpResponse()
  • draftSelfReport()
  • getAccountFileSize()
  • importVcard(), parseVcard(), makeVcard()
  • sendWebxdcRealtimeData, sendWebxdcRealtimeAdvertisement(), leaveWebxdcRealtime()
Parameters
jsonrpc_instancejsonrpc instance as returned from dc_jsonrpc_init().
requestJSON-RPC request as string

◆ dc_jsonrpc_unref()

void dc_jsonrpc_unref ( dc_jsonrpc_instance_t * jsonrpc_instance)

Free a jsonrpc instance.

Parameters
jsonrpc_instancejsonrpc instance as returned from dc_jsonrpc_init(). If NULL is given, nothing is done and an error is logged.

The documentation for this class was generated from the following file: