[][src]Type Definition dart_sys::Dart_ServiceRequestCallback

type Dart_ServiceRequestCallback = Option<unsafe extern "C" fn(method: *const c_char, param_keys: *mut *const c_char, param_values: *mut *const c_char, num_params: isize, user_data: *mut c_void, json_object: *mut *const c_char) -> bool>;

A service request callback function.

These callbacks, registered by the embedder, are called when the VM receives a service request it can't handle and the service request command name matches one of the embedder registered handlers.

The return value of the callback indicates whether the response should be used as a regular result or an error result. Specifically, if the callback returns true, a regular JSON-RPC response is built in the following way:

{ "jsonrpc": "2.0", "result": <json_object>, "id": , }

If the callback returns false, a JSON-RPC error is built like this:

{ "jsonrpc": "2.0", "error": <json_object>, "id": , }

\param method The rpc method name. \param param_keys Service requests can have key-value pair parameters. The keys and values are flattened and stored in arrays. \param param_values The values associated with the keys. \param num_params The length of the param_keys and param_values arrays. \param user_data The user_data pointer registered with this handler. \param result A C string containing a valid JSON object. The returned pointer will be freed by the VM by calling free.

\return True if the result is a regular JSON-RPC response, false if the result is a JSON-RPC error.