X-Git-Url: https://git.cworth.org/git?p=ttt;a=blobdiff_plain;f=src%2Fttt-server.h;h=77fb4bf79df7c023a2f971b27015131b8e7e09e9;hp=b8d2496e2149d44285b302a14d6fb28da13714a7;hb=907321c065fb1383e800f0794981df91d4327f57;hpb=15672ac8305a1c5ba0d9bf6edabb0a194c30628e diff --git a/src/ttt-server.h b/src/ttt-server.h index b8d2496..77fb4bf 100644 --- a/src/ttt-server.h +++ b/src/ttt-server.h @@ -24,9 +24,36 @@ #ifndef _TTT_SERVER_H_ #define _TTT_SERVER_H_ -typedef struct _ttt_server ttt_server_t; +/* Register a new client with the server. + * + * Returns: the unique id of the client. + * + * Locking: The server mutex will be acquired and held throughout the + * execution of this function. + * + * Errors: If an error (such as out-of-memory) occurs, this function + * will not return. + */ +int +ttt_server_register_client (ttt_server_t *server, ttt_client_t *client); -/* Send a message to all connected clients. */ +/* Un-register a client from the server. + * + * Locking: The server mutex will be acquired and held throughout the + * execution of this function. + */ +void +ttt_server_unregister_client (ttt_server_t *server, ttt_client_t *client); + +/* Send a message to all connected clients. + * + * Locking: The server mutex will be acquired and held throughout the + * execution of this function. Each client mutex may also be acquired + * and held by functions called during the execution of this function. + * + * Errors: If an error such as an IO error occurs, this function will + * not return. + */ void ttt_server_broadcast (ttt_server_t *server, const char *message);