]> git.cworth.org Git - ttt/blobdiff - src/ttt-server.h
2005-12-10 Richard D. Worth <richard@theworths.org>
[ttt] / src / ttt-server.h
index b8d2496e2149d44285b302a14d6fb28da13714a7..80f22bf25b0ffa9ce1884931e59524966fcc5a27 100644 (file)
  */
 
 #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);
 
+
+/* Returns the WHO response. The return string is allocated in this
+ * function and will need to be free'd by the caller.
+ *
+ * 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.
+ */
+const char*
+ttt_server_who (ttt_server_t *server);
+
+/* Checks to see whether a username exists.
+ *
+ * Returns: ttt_server_get_client_from_username(server, username)
+ *
+ * Locking: See ttt_server_get_client_from_username
+ *
+ * Errors: See ttt_server_get_client_from_username
+ */
+ttt_error_t
+ttt_server_verify_username (ttt_server_t *server,
+                           const char *username);
+
+/* Points *client to the client with the supplied username, else
+ * leaves *client unhanged.
+ * 
+ * Returns: TTT_ERROR_NONE, else TTT_ERROR_NO_USER if username not
+ * found. 
+ *
+ * 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.
+ */
+ttt_error_t
+ttt_server_get_client_from_username (ttt_server_t *server,
+                                    const char   *username,
+                                    ttt_client_t **client);
+
+/* Adds an invitation
+ * 
+ * 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.
+ */
+ttt_error_t
+ttt_server_add_invite (ttt_server_t *server,
+                      ttt_client_t *actor,
+                      ttt_client_t *invitee);
+
+/* Removes an invitation
+ *
+ * Returns: TTT_ERROR_NONE, else TTT_ERROR_NO_INVITE if no invite
+ * found.
+ * 
+ * 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.
+ */
+ttt_error_t
+ttt_server_remove_invite (ttt_server_t *server,
+                         ttt_client_t *actor,
+                         ttt_client_t *invitee);
+
+/* 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_ */