Waltham
0.1.0
|
Common and exclusive API for servers. More...
Modules | |
Common API for both server and client | |
Typedefs | |
typedef void(* | wth_connection::wth_registry_callback_func) (struct wthp_registry *registry, void *user_data) |
Prototype of the callback to be called whenever a client creates a registry. More... | |
Functions | |
struct wth_connection * | wth_connection::wth_accept (int sockfd, struct sockaddr *addr, socklen_t *addrlen) |
Accept a Waltham client connection. More... | |
void | wth_connection::wth_connection_set_registry_callback (struct wth_connection *conn, wth_registry_callback_func registry_callback, void *user_data) |
Set the callback to be called once a client creates a registry. More... | |
void | wth_connection::wth_connection_post_error_no_memory (struct wth_connection *conn) |
Post an out of memory display error. More... | |
void | wth_object::wth_object_post_error (struct wth_object *obj, uint32_t code, const char *fmt,...) |
Post a fatal protocol error to a client. More... | |
Common and exclusive API for servers.
These functions are exclusive to a server. They will abort the program if called in the context of a client-side wth_connection. For the common functions, see Common API for both server and client.
typedef void(* wth_registry_callback_func) (struct wthp_registry *registry, void *user_data) |
Prototype of the callback to be called whenever a client creates a registry.
registry | The registry which has been created. |
user_data | The data set in wth_connection_set_registry_callback, generally identifying the client this registry pertains to. |
A function implementing this callback will receive a pointer to the newly-created registry, as well as the data previously set in wth_connection_set_registry_callback.
struct wth_connection * wth_accept | ( | int | sockfd, |
struct sockaddr * | addr, | ||
socklen_t * | addrlen | ||
) |
Accept a Waltham client connection.
sockfd | A listening socket file descriptor to extract a connection from. |
addr | Address of the connecting client. |
addrlen | Size of addr. |
See accept(2) for the documentation of the arguments.
This creates a server-side wth_connection, representing a single connected client, by accepting a new connection from the listening socket.
void wth_connection_post_error_no_memory | ( | struct wth_connection * | conn | ) |
Post an out of memory display error.
conn | The Waltham connection. |
Post the out of memory error on the internal display object.
void wth_connection_set_registry_callback | ( | struct wth_connection * | conn, |
wth_registry_callback_func | registry_callback, | ||
void * | user_data | ||
) |
Set the callback to be called once a client creates a registry.
conn | The Waltham connection. |
registry_callback | The registry callback. |
user_data | Any data to be passed to the callback, generally related to the client expected to create registries. |
The callback will be stored inside of the connection, and will be called each time the client creates a registry.
void wth_object_post_error | ( | struct wth_object * | obj, |
uint32_t | code, | ||
const char * | fmt, | ||
... | |||
) |
Post a fatal protocol error to a client.
obj | The object that specifies the error code. |
code | The error code, specific to the object's interface. |
fmt | A freeform description of the error for human readers; printf-style format string. |
This call sends the protocol error event to the client, and sets the associated wth_connection into protocol error state. As a result, no further events will reach the client, and no requests from the client will be dispatched.
After calling this, the server is expected to keep the wth_connection open until the client disconnects. This ensures the error event reaches the client.
Clients cannot use this function.