1 /* ttt-server.c - tic-tac-toe game server
3 * Copyright © 2005 Carl Worth
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software Foundation,
17 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 * Author: Carl Worth <cworth@cworth.org>
23 #include "ttt-error.h"
25 #ifndef _TTT_SERVER_H_
26 #define _TTT_SERVER_H_
28 /* Register a new client with the server.
30 * Returns: TTT_ERROR_NONE on success, else TTT_ERROR_INVALIDNAME if client's
33 * Locking: The server mutex will be acquired and held throughout the
34 * execution of this function.
36 * Errors: If an error (such as out-of-memory) occurs, this function
40 ttt_server_register_client (ttt_server_t *server, ttt_client_t *client);
42 /* Un-register a client from the server.
44 * Locking: The server mutex will be acquired and held throughout the
45 * execution of this function.
48 ttt_server_unregister_client (ttt_server_t *server, ttt_client_t *client);
50 /* Send a message to all connected clients.
52 * Locking: The server mutex will be acquired and held throughout the
53 * execution of this function. Each client mutex may also be acquired
54 * and held by functions called during the execution of this function.
56 * Errors: If an error such as an IO error occurs, this function will
60 ttt_server_broadcast (ttt_server_t *server, const char *message);
63 /* Returns the WHO response. The return string is allocated in this
64 * function and will need to be free'd by the caller.
66 * Locking: The server mutex will be acquired and held throughout the
67 * execution of this function. Each client mutex may also be acquired
68 * and held by functions called during the execution of this function.
70 * Errors: If an error such as an IO error occurs, this function will
74 ttt_server_who (ttt_server_t *server);
76 /* Generates the statistics for the user. If the function does not
77 * return an error, the response will be allocated in this function
78 * and will need to be free'd by the caller.
80 * Locking: The server mutex will be acquired and held throughout the
81 * execution of this function. Each client mutex may also be acquired
82 * and held by functions called during the execution of this function.
84 * Errors: If an error such as an IO error occurs, this function will
88 ttt_server_statistics (ttt_server_t *server,
92 /* Gets the server hostname.
96 ttt_server_get_host (ttt_server_t *server);
98 /* Gets the server port
102 ttt_server_get_port (ttt_server_t *server);
104 #endif /* _TTT_SERVER_H_ */