Provides all utility client functions. More...
#include "quickio.h"Go to the source code of this file.
Classes | |
| struct | client_sub |
| Information about the client's subscription to an event. More... | |
| struct | client_cb |
| Information necessary to fire a callback. More... | |
| struct | client |
| Everything that a client needs to function. More... | |
Enumerations | |
| enum | client_sub_state { CLIENT_SUB_PENDING, CLIENT_SUB_TOMBSTONED, CLIENT_SUB_CREATED, CLIENT_SUB_ACTIVE, CLIENT_SUB_NULL } |
| Client subscriptions go through multiple states, explained here. More... | |
Functions | |
| evs_cb_t | client_cb_new (struct client *client, const evs_cb_fn cb_fn, void *cb_data, const qev_free_fn free_fn) |
| Creates a callback for the client. More... | |
| enum evs_status | client_cb_fire (struct client *client, const evs_cb_t server_cb, const evs_cb_t client_cb, gchar *json) |
| Fires a callback and frees up everything associated with it. More... | |
| void | client_cb_prune (struct client *client, const gint64 before) |
| Prune any client callbacks that have been hanging around too long. | |
| gint64 | client_cb_prune_get_before () |
| Get the time before which callbacks should be pruned. | |
| gboolean | client_sub_active (struct client *client, struct subscription *sub) |
| Checks if a client is subscribed to the given susbcription. More... | |
| enum client_sub_state | client_sub_add (struct client *client, struct subscription *sub) |
| Adds the subscription to the client. More... | |
| enum client_sub_state | client_sub_accept (struct client *client, struct subscription *sub) |
| Marks the subscription as accepted. More... | |
| void | client_sub_reject (struct client *client, struct subscription *sub) |
| Removes a pending subscription. More... | |
| gboolean | client_sub_remove (struct client *client, struct subscription *sub) |
| Removes the subscription from the client. More... | |
| void | client_update_subs_config (const guint64 total, const guint64 pressure, const guint64 min) |
| For configuration values: update the fair pool for subs. More... | |
| void | client_set (struct client *client, const GQuark key, GVariant *val) |
| Sets a piece of data on a client. More... | |
| GVariant * | client_get (struct client *client, const GQuark key) |
| Gets some data from a client. More... | |
| gboolean | client_has (struct client *client, const GQuark key) |
| Check if the client has anything set for the given key. More... | |
| void | client_del (struct client *client, const GQuark key) |
| Remove the key from the client. More... | |
| void | client_closed (struct client *client) |
| A client closed and it should start to be cleaned up. | |
| void | client_free_all (struct client *client) |
| A client is being freed and should be completely cleaned up. | |
| void | client_init () |
| Initialize clients data. | |
Provides all utility client functions.
| enum client_sub_state |
Client subscriptions go through multiple states, explained here.
| Enumerator | |
|---|---|
| CLIENT_SUB_PENDING |
The subscription already exists and is in the pending state (probably went async with verification). |
| CLIENT_SUB_TOMBSTONED |
The subscription exists and is going to be removed, but evs_on_cb() hasn't been called by the owner, so removal is being delayed until then. |
| CLIENT_SUB_CREATED |
The subscription was created and is in the pending state. |
| CLIENT_SUB_ACTIVE |
The subscription is active and valid. |
| CLIENT_SUB_NULL |
The client has no such subscription. |
| enum evs_status client_cb_fire | ( | struct client * | client, |
| const evs_cb_t | server_cb, | ||
| const evs_cb_t | client_cb, | ||
| gchar * | json | ||
| ) |
Fires a callback and frees up everything associated with it.
| client | The client to create a callback for |
| server_cb | The callback ID the client sent back for the server. |
| client_cb | The id of the callback to send to the client |
| json | Data sent with the callback |
| evs_cb_t client_cb_new | ( | struct client * | client, |
| const evs_cb_fn | cb_fn, | ||
| void * | cb_data, | ||
| const qev_free_fn | free_fn | ||
| ) |
Creates a callback for the client.
If cb_fn is NULL and cb_data is not, it is cleaned up with free_fn, and EVS_NO_CALLBACK is returned.
| client | The client to create a callback for |
| cb_fn | The function to call when the client triggers the callback. [not-null] |
| cb_data | Data to come with the callback [transfer-full] |
| free_fn | Frees cb_data |
| void client_del | ( | struct client * | client, |
| const GQuark | key | ||
| ) |
Remove the key from the client.
| client | The client to get the data from |
| key | The key to remove |
| GVariant* client_get | ( | struct client * | client, |
| const GQuark | key | ||
| ) |
Gets some data from a client.
| client | The client to get the data from |
| key | The key to lookup |
| gboolean client_has | ( | struct client * | client, |
| const GQuark | key | ||
| ) |
Check if the client has anything set for the given key.
| client | The client to get the data from |
| key | The key to lookup |
| void client_set | ( | struct client * | client, |
| const GQuark | key, | ||
| GVariant * | val | ||
| ) |
Sets a piece of data on a client.
| client | The client to set the data on |
| key | The name of the value to set |
| val | The value for the key. Assumes full ownership over any floating reference. May not be NULL. |
| enum client_sub_state client_sub_accept | ( | struct client * | client, |
| struct subscription * | sub | ||
| ) |
Marks the subscription as accepted.
| client | The client to accept the subscription on |
| sub | The subscription to accept |
| gboolean client_sub_active | ( | struct client * | client, |
| struct subscription * | sub | ||
| ) |
Checks if a client is subscribed to the given susbcription.
| client | The client in question |
| sub | The subscription in question [transfer-none] |
| enum client_sub_state client_sub_add | ( | struct client * | client, |
| struct subscription * | sub | ||
| ) |
Adds the subscription to the client.
| client | The client in question |
| sub | The subscription in question |
| void client_sub_reject | ( | struct client * | client, |
| struct subscription * | sub | ||
| ) |
Removes a pending subscription.
| client | The client to reject the subscription on |
| sub | The subscription to reject |
| gboolean client_sub_remove | ( | struct client * | client, |
| struct subscription * | sub | ||
| ) |
Removes the subscription from the client.
| client | The client in question |
| sub | The subscription in question [transfer-none] |
| void client_update_subs_config | ( | const guint64 | total, |
| const guint64 | pressure, | ||
| const guint64 | min | ||
| ) |
For configuration values: update the fair pool for subs.
| total | The new total to use |
| pressure | The new pressure value to use |
| min | The new min value to use |
1.8.6