18 #define EVS_NO_CALLBACK (0l)
33 const gchar *ev_extra,
45 const gchar *ev_extra);
232 const gchar *ev_path,
236 const gboolean handle_children);
263 const gchar *ev_prefix,
305 const gchar *ev_prefix,
307 const gchar *ev_extra);
323 struct client *client,
342 struct client *client,
360 struct client *client,
362 const gchar *ev_extra,
386 struct client *client,
409 struct client *client,
411 const gchar *ev_extra,
455 struct client *client,
488 struct client *client,
489 const gchar *ev_prefix,
491 const gchar *ev_extra,
508 const gboolean success,
524 const gboolean with_ev_extra);
546 struct client *client,
573 struct client *client,
597 struct client *client,
621 struct client *client,
624 const gchar *err_msg,
657 struct client *client,
660 const gchar *err_msg,
695 const gchar *ev_path,
void evs_cb_with_cb(struct client *client, const evs_cb_t client_cb, const gchar *json, const evs_cb_fn cb_fn, void *cb_data, const qev_free_fn free_fn)
Sends a CODE_OK callback to a client while requesting a callback from the client. ...
void evs_init()
Initialize the stats in events.
void evs_on_info_free(struct evs_on_info *info)
Clean up the copy of struct evs_on_info, releasing any references made.
A previous request for the exact same thing is currently being processed.
Definition: evs.h:104
Malformed data was sent.
Definition: evs.h:109
evs_status
From handlers, these values instruct the server how to handle everything.
Definition: evs.h:59
guint64 evs_cb_t
Callbacks are just gigantic integers, 0 meaning "no callback".
Definition: evs.h:23
Everything went as expected.
Definition: evs.h:99
void evs_cb_full(struct client *client, const evs_cb_t client_cb, const enum evs_code code, const gchar *err_msg, const gchar *json, const evs_cb_fn cb_fn, void *cb_data, const qev_free_fn free_fn)
Sends a callback to a client, with all possible data.
void evs_broadcast_tick()
Do the actual event broadcasting.
guint evs_clean_path(gchar *ev_path)
Given an arbitrary, full path, clean it up entirely (in place) so that it conforms with QIO standards...
evs_code
Codes used for callbacks.
Definition: evs.h:95
void event_init(struct event *ev, const gchar *ev_path, const evs_handler_fn handler_fn, const evs_on_fn on_fn, const evs_off_fn off_fn, const gboolean handle_children)
Intialize a new struct event
struct client * client
Can be 1 of 3 things, depending on client type: 1) If the client is a surrogate, then points to the c...
Definition: client.h:224
You're not allowed to do that.
Definition: evs.h:114
Events are stored in a prefix tree for fast, nice lookups.
Definition: evs.h:184
void evs_send(struct client *client, struct event *ev, const gchar *ev_extra, const gchar *json)
Sends an event to a specific client.
Yeah, I'm going to need you to go ahead and not use something that doesn't exist. ...
Definition: evs.h:120
void evs_err_cb(struct client *client, const evs_cb_t client_cb, const enum evs_code code, const gchar *err_msg, const gchar *json)
Sends a callback to a client with an error code and message.
The server understood the request but needs to client to calm down.
Definition: evs.h:126
struct event * evs_add_handler(const gchar *ev_prefix, const gchar *ev_path, const evs_handler_fn handler_fn, const evs_on_fn on_fn, const evs_off_fn off_fn, const gboolean handle_children)
Creates a handler for an event.
void evs_send_sub(struct client *client, struct subscription *sub, const gchar *json)
Sends an event to a specific client.
void evs_on_cb(const gboolean success, const struct evs_on_info *info)
Subscribes a client to an event without any callback checks.
struct client * client
The client that sent the subscription.
Definition: evs.h:155
evs_on_fn on_fn
Called when client attempts to subscribe to event.
Definition: evs.h:198
GString * evs_make_path(const gchar *ev_prefix, const gchar *ev_path, const gchar *ev_extra)
Given a path, make it such that is matches exactly what QIO expects paths to be.
gchar * ev_path
The event path for this node.
Definition: evs.h:188
void evs_client_close(struct client *client)
Cleans up after the client when it closes.
void evs_send_info(const struct evs_on_info *info, const gchar *json)
Sends an event to a specific client.
void evs_route(struct client *client, gchar *ev_path, const evs_cb_t client_cb, gchar *json)
Routes an event from a client.
GRWLock subs_lock
Lock for subs.
Definition: evs.h:224
Everything that a client needs to function.
Definition: client.h:100
void evs_send_sub_full(struct client *client, struct subscription *sub, const gchar *json, const evs_cb_fn cb_fn, void *cb_data, const qev_free_fn free_fn)
Sends an event to a specific client, requesting a callback from the client.
enum evs_status(* evs_on_fn)(const struct evs_on_info *info)
The handler for when a client subscribes.
Definition: evs.h:179
void evs_cb(struct client *client, const evs_cb_t client_cb, const gchar *json)
Sends a CODE_OK callback to a client.
GHashTable * data
Any extra data that can be attached to a client using client_{get,set,del,has}(). ...
Definition: client.h:158
void evs_send_full(struct client *client, struct event *ev, const gchar *ev_extra, const gchar *json, const evs_cb_fn cb_fn, void *cb_data, const qev_free_fn free_fn)
Sends an event to a specific client, requesting a callback from the client.
void evs_broadcast(struct event *ev, const gchar *ev_extra, const gchar *json)
Broadcast a message to all clients listening on the event.
evs_cb_t client_cb
The callback id to be sent.
Definition: evs.h:160
Information necessary to fire a callback.
Definition: client.h:70
struct subscription * sub
Reference to the susbcription.
Definition: evs.h:150
void evs_send_info_full(const struct evs_on_info *info, const gchar *json, const evs_cb_fn cb_fn, void *cb_data, const qev_free_fn free_fn)
Sends an event to a specific client, requesting a callback from the client.
struct evs_on_info * evs_on_info_copy(const struct evs_on_info *info, const gboolean with_ev_extra)
Make a copy of the evs_on_info(), returning a reference that is safe to use from another thread...
void evs_pre_init()
Initialize events.
gchar * ev_extra
Any extra parameters sent with the event.
Definition: evs.h:145
Every header, definition, and whatnot QuickIO needs to run.
evs_handler_fn handler_fn
Function called when client sends event to the server.
Definition: evs.h:193
void evs_send_bruteforce(struct client *client, const gchar *ev_prefix, const gchar *ev_path, const gchar *ev_extra, const gchar *json, const evs_cb_fn cb_fn, void *cb_data, const qev_free_fn free_fn)
Send an event to a client, damn the consequences.
The event was handled and any necessary callbacks (including error callbacks) have been dispatched by...
Definition: evs.h:87
The event was handled and a default callback should be sent, if the client requested.
Definition: evs.h:67
void evs_broadcast_path(const gchar *ev_path, const gchar *json)
Broadcast a message to all clients listening on the event.
GHashTable * subs
All of the children subscriptions to this event, referenced by extra path segments.
Definition: evs.h:219
void evs_client_offd(struct client *client, struct subscription *sub)
The client was unsubscribed from an event, and any callbacks should be fired immediately.
There was an error with the handler and a generic error should be sent back to the client...
Definition: evs.h:76
An unknown error occurred.
Definition: evs.h:131
Contains all the fields necessary to send a callback to a client about a subscription.
Definition: evs.h:141
void evs_on(struct client *client, struct event *ev, gchar *ev_extra, const evs_cb_t client_cb)
Subscribes the client to the event, checking with the event's subscriber callback that such things ar...
evs_off_fn off_fn
Called when client unsubscribes from event.
Definition: evs.h:203
void(* qev_free_fn)(void *)
Function type for a typical free function.
Definition: qev.h:185
Events are what are located at the paths, whereas subscriptions are what are located at ev_path + ev_...
Definition: sub.h:20
void(* evs_off_fn)(struct client *client, const gchar *ev_extra)
The handler for when a client unsubscribes.
Definition: evs.h:43
enum evs_status(* evs_handler_fn)(struct client *client, const gchar *ev_extra, const evs_cb_t client_cb, gchar *json)
The handler function type.
Definition: evs.h:31
void evs_off(struct client *client, struct event *ev, const gchar *ev_extra)
Remove a client from an event.
enum evs_status evs_no_on(const struct evs_on_info *info)
Doesn't allow anyone to subscribe to the event.
enum evs_status(* evs_cb_fn)(struct client *client, const void *data, const evs_cb_t client_cb, gchar *json)
Function called when the client sends a callback to the server.
Definition: evs.h:50
void event_clear(struct event *ev)
Clean up all memory inside a struct event
gboolean handle_children
If this event wants to handle all children paths.
Definition: evs.h:208