]> git.cworth.org Git - ttt/blob - src/ttt-server.h
2005-11-15 Carl Worth <cworth@cworth.org>
[ttt] / src / ttt-server.h
1 /* ttt-server.c - tic-tac-toe game server
2  *
3  * Copyright © 2005 Carl Worth
4  *
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)
8  * any later version.
9  *
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.
14  *
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.
18  *
19  * Author: Carl Worth <cworth@cworth.org>
20  */
21
22 #include "ttt.h"
23
24 #ifndef _TTT_SERVER_H_
25 #define _TTT_SERVER_H_
26
27 /* Register a new client with the server.
28  *
29  * Returns: the unique id of the client.
30  *
31  * Locking: The server mutex will be acquired and held throughout the
32  * execution of this function.
33  *
34  * Errors: If an error (such as out-of-memory) occurs, this function
35  * will not return.
36  */
37 int
38 ttt_server_register_client (ttt_server_t *server, ttt_client_t *client);
39
40 /* Un-register a client from the server.
41  *
42  * Locking: The server mutex will be acquired and held throughout the
43  * execution of this function.
44  */
45 void
46 ttt_server_unregister_client (ttt_server_t *server, ttt_client_t *client);
47
48 /* Send a message to all connected clients.
49  *
50  * Locking: The server mutex will be acquired and held throughout the
51  * execution of this function. Each client mutex may also be acquired
52  * and held by functions called during the execution of this function.
53  *
54  * Errors: If an error such as an IO error occurs, this function will
55  * not return.
56  */
57 void
58 ttt_server_broadcast (ttt_server_t *server, const char *message);
59
60 #endif /* _TTT_SERVER_H_ */