Waltham  0.1.0
Modules | Typedefs | Functions
Server API

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_connectionwth_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...
 

Detailed Description

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 Documentation

◆ wth_registry_callback_func

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.

Parameters
registryThe registry which has been created.
user_dataThe 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.

See also
wth_connection_set_registry_callback
wth_connection_create_registry

Function Documentation

◆ wth_accept()

struct wth_connection * wth_accept ( int  sockfd,
struct sockaddr *  addr,
socklen_t *  addrlen 
)

Accept a Waltham client connection.

Parameters
sockfdA listening socket file descriptor to extract a connection from.
addrAddress of the connecting client.
addrlenSize 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.

◆ wth_connection_post_error_no_memory()

void wth_connection_post_error_no_memory ( struct wth_connection conn)

Post an out of memory display error.

Parameters
connThe Waltham connection.

Post the out of memory error on the internal display object.

◆ wth_connection_set_registry_callback()

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.

Parameters
connThe Waltham connection.
registry_callbackThe registry callback.
user_dataAny 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.

See also
wth_connection_create_registry

◆ wth_object_post_error()

void wth_object_post_error ( struct wth_object obj,
uint32_t  code,
const char *  fmt,
  ... 
)

Post a fatal protocol error to a client.

Parameters
objThe object that specifies the error code.
codeThe error code, specific to the object's interface.
fmtA 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.