Events Model

When application allocates new AislInstance, it shall provide a callback that will handle events triggered by AISL.

/* @file aisl/types.h */

#define AISL_CALLBACK(x) ((AislCallback) x)

typedef void
(* AislCallback) (const struct aisl_evt *evt, void *p_ctx);

First argument const struct aisl_evt *evt contains all necessary data for event handling.

Second argument is a user-defined pointer, that AISL will pass through form configuration structure.


struct aisl_evt {
	void         *source;
	AislEvent     code;
	AislStatus    status;
};

Application should check code value and cast source pointer as an appropriate type. Property status let application to know the status of operation that triggered the event.

Server events

Events that has AislServer as their source.

Client events

Events that has AislClient as their source.

Stream events

Events that has AislStream as their source.

Event payload received in a callback can be also type casted in several cases for additional data:

struct aisl_evt_open {
	struct aisl_evt   evt;           /**< generic #aisl_evt structure */
	const char       *path;          /**< HTTP request path */
	const char       *query;         /**< HTTP request query (GET params) */
	AislHttpMethod    http_method;   /**< HTTP request method */
};
struct aisl_evt_header {
	struct aisl_evt   evt;           /**< generic #aisl_evt structure */
	const char       *key;           /**< low case HTTP header name */
	const char       *value;         /**< HTTP header string */
};
struct aisl_evt_input {
	struct aisl_evt   evt;           /**< generic #aisl_evt structure */
	const char       *data;          /**< a pointer to received data array */
	int32_t           size;          /**< data array size */
};

Functions


Function aisl_event_to_string

Converts AislEvent constant to a NULL-terminated string representation.

const char *
aisl_event_to_string(AislEvent evt);

Arguments

Return value

A NULL-terminated string representation of AislEvent