X-Git-Url: https://git.cworth.org/git?p=ttt;a=blobdiff_plain;f=src%2Fttt-server.h;h=7cf3d9707ecc95aec9bbfa8e02dc8a20ea9d1137;hp=b8d2496e2149d44285b302a14d6fb28da13714a7;hb=84db9bf52aa25c19f7d547ea2dbec69ca4452300;hpb=15672ac8305a1c5ba0d9bf6edabb0a194c30628e diff --git a/src/ttt-server.h b/src/ttt-server.h index b8d2496..7cf3d97 100644 --- a/src/ttt-server.h +++ b/src/ttt-server.h @@ -20,14 +20,55 @@ */ #include "ttt.h" +#include "ttt-error.h" #ifndef _TTT_SERVER_H_ #define _TTT_SERVER_H_ -typedef struct _ttt_server ttt_server_t; +/* Register a new client with the server. + * + * Returns: TTT_ERROR_NONE on success, else TTT_ERROR_INVALIDNAME if client's + * name is not unique. + * + * 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. + */ +ttt_error_t +ttt_server_register_client (ttt_server_t *server, ttt_client_t *client); + +/* 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. */ +/* 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); +/* Gets the server hostname. + * + */ +const char* +ttt_server_get_host (ttt_server_t *server); + +/* Gets the server port + * + */ +const char* +ttt_server_get_port (ttt_server_t *server); + #endif /* _TTT_SERVER_H_ */