|
libamxb
4.8.2
Bus Agnostic C API
|
Data Structures | |
| struct | _amxb_request |
| A request structure. More... | |
Functions | |
| int | amxb_new_invoke (amxb_invoke_t **invoke_ctx, amxb_bus_ctx_t *const ctx, const char *object, const char *interface, const char *method) |
| Prepares a remote function invocation. More... | |
| void | amxb_free_invoke (amxb_invoke_t **invoke_ctx) |
| Deletes a function invoke context, and frees allocated memory. More... | |
| int | amxb_invoke (amxb_invoke_t *invoke_ctx, amxc_var_t *args, amxc_var_t *ret, amxb_be_cb_fn_t fn, void *priv, int timeout) |
| Invokes a remote function, as defined by the function invoke context. More... | |
| int | amxb_async_invoke (amxb_invoke_t *invoke_ctx, amxc_var_t *args, amxb_be_cb_fn_t fn, amxb_be_done_cb_fn_t done_fn, void *priv, amxb_request_t **req) |
| Invokes a remote function, as defined by the function invoke context. More... | |
| int | amxb_wait_for_request (amxb_request_t *req, int timeout) |
| Waits for an asynchronous remote function invoke to finish. More... | |
| int | amxb_request_new (amxb_request_t **request) |
| Allocates an empty amxb_request_t. More... | |
| amxb_bus_ctx_t * | amxb_request_get_ctx (amxb_request_t *request) |
| Get the bus context of the request if any. More... | |
| int | amxb_close_request (amxb_request_t **req) |
| Closes a previously create remote function called context. More... | |
| int amxb_async_invoke | ( | amxb_invoke_t * | invoke_ctx, |
| amxc_var_t * | args, | ||
| amxb_be_cb_fn_t | fn, | ||
| amxb_be_done_cb_fn_t | done_fn, | ||
| void * | priv, | ||
| amxb_request_t ** | req | ||
| ) |
Invokes a remote function, as defined by the function invoke context.
Before invoking a function, an function invoke context must be created using amxb_new_invoke.
This method returns immediately, without waiting for the result (asynchronous I/O), to be able to receive the result of remote function call it is recommended that you use an eventloop.
The arguments passed must be in a amxc variant of type AMXC_VAR_ID_HTABLE. The order of the arguments is not important.
A callback function can be given, which is called for each individual return value. The private data will be passed to the callback function. If no callback function is given, the return values can be fetched from the request context, see _amxb_request
A done callback function can be given, which is called when the remote function call is finished. The private data will be passed to the done callback function. It is recommended to provide a done function, unless you are not interested when the remote function is done.
| invoke_ctx | The function invoke context as created with amxb_new_invoke |
| args | the function arguments in a amxc variant htable type |
| fn | a callback function |
| done_fn | a done callback function |
| priv | private data that will be passed to the callback function (optional, can be NULL) |
| req | the request context. |
Definition at line 396 of file amxb_ba_invoke.c.
| int amxb_close_request | ( | amxb_request_t ** | req | ) |
Closes a previously create remote function called context.
Deletes and frees the request context created with amxb_async_invoke.
When the context is deleted, none of the callback functions will be called, not event when the remote function call was not yet finished.
| req | The remote function invoke request |
Definition at line 498 of file amxb_ba_invoke.c.
| void amxb_free_invoke | ( | amxb_invoke_t ** | invoke_ctx | ) |
Deletes a function invoke context, and frees allocated memory.
Frees the allocated memory for the function invoke context.
| invoke_ctx | The function invoke context, is reset to NULL |
Definition at line 324 of file amxb_ba_invoke.c.
| int amxb_invoke | ( | amxb_invoke_t * | invoke_ctx, |
| amxc_var_t * | args, | ||
| amxc_var_t * | ret, | ||
| amxb_be_cb_fn_t | fn, | ||
| void * | priv, | ||
| int | timeout | ||
| ) |
Invokes a remote function, as defined by the function invoke context.
Before invoking a function, an function invoke context must be created using amxb_new_invoke.
This method is blocking, it will return when the remote function call is done or when it has failed.
The arguments passed must be in a amxc variant of type AMXC_VAR_ID_HTABLE. The order of the arguments is not important.
The return value must be an initialized amxc variant, the type must not be set.
Optionally a callback function can be given, which is called for each individual return value. The private data will be passed to the callback function.
As this function is blocking, a time out in seconds, must be provided. If the remote function call is not done in the given timeout, the function call (on the client side) is aborted.
| invoke_ctx | The function invoke context as created with amxb_new_invoke |
| args | the function arguments in a amxc variant htable type |
| ret | when the remote function call is done, it will contain an array of return values. |
| fn | a callback function (optional, can be NULL). |
| priv | private data that will be passed to the callback function (optional, can be NULL) |
| timeout | in seconds |
Definition at line 352 of file amxb_ba_invoke.c.
| int amxb_new_invoke | ( | amxb_invoke_t ** | invoke_ctx, |
| amxb_bus_ctx_t *const | ctx, | ||
| const char * | object, | ||
| const char * | interface, | ||
| const char * | method | ||
| ) |
Prepares a remote function invocation.
Allocates a remote function invoke context. Depending on the bus specific backend used, this function prepares the remote function invoke.
The created function invoke context can be re-used many times to call the same function.
| invoke_ctx | The place where the function invoke context is stored |
| ctx | the bus connection context |
| object | the path to the object (mandatory) |
| interface | the interface name, that contains the function (optional) when not used provide a NULL pointer |
| method | the name of the function that is going to be called (mandatory) |
Definition at line 281 of file amxb_ba_invoke.c.
| amxb_bus_ctx_t* amxb_request_get_ctx | ( | amxb_request_t * | request | ) |
Get the bus context of the request if any.
Returns the bus context for which the request was created.
| request | the request pointer |
Definition at line 484 of file amxb_ba_invoke.c.
| int amxb_request_new | ( | amxb_request_t ** | request | ) |
Allocates an empty amxb_request_t.
Allocates and initializes an empty amxb_request_t.
This function is mainly intended for use in back-end implementations. Client applications should use amxb_async_invoke to allocate and initialize such a structure.
| request | the request pointer to initialize |
Definition at line 470 of file amxb_ba_invoke.c.
| int amxb_wait_for_request | ( | amxb_request_t * | req, |
| int | timeout | ||
| ) |
Waits for an asynchronous remote function invoke to finish.
Waits until a remote function invoke, created with amxb_async_invoke is finished.
When a done callback was provided, the done callback will be called before this function returns, unless a timeout occurs.
| req | The remote function invoke request |
| timeout | in seconds |
Definition at line 442 of file amxb_ba_invoke.c.