]> git.cworth.org Git - loudgame/blob - loudgame.h
Add loudgame_broadcast and a simple hash table to announce new users to each other.
[loudgame] / loudgame.h
1 /*
2  * Copyright (C) 2008 Carl Worth
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see http://www.gnu.org/licenses/ .
16  *
17  * Author: Carl Worth <cworth@cworth.org>
18  */
19
20 #ifndef __LOUDGAME_H__
21 #define __LOUDGAME_H__
22
23 #include <stdarg.h>
24 #include <loudmouth/loudmouth.h>
25
26 typedef struct _loudgame loudgame_t;
27
28 typedef void (*handle_message_cb) (loudgame_t   *lg,
29                                    const char   *peer,
30                                    const char   *message);
31
32 struct _loudgame {
33     gchar               *server;
34     gchar               *name;
35     gchar               *passwd;
36     LmConnection        *connection;
37
38     GMainLoop           *main_loop;
39     GHashTable          *players;
40
41     int                  return_value;
42
43     /* Callbacks */
44     handle_message_cb    handle_message;
45 };
46
47 int
48 loudgame_init (loudgame_t *lg, int argc, char **argv);
49
50 int
51 loudgame_run (loudgame_t *lg);
52
53 void
54 loudgame_send (loudgame_t       *lg,
55                const char       *peer,
56                const char       *message);
57
58 void
59 loudgame_sendf (loudgame_t      *lg,
60                 const char      *peer,
61                 const char      *format,
62                 ...);
63
64 void
65 loudgame_vsendf (loudgame_t     *lg,
66                  const char     *peer,
67                  const char     *format,
68                  va_list         va);
69
70 void
71 loudgame_quit (loudgame_t *lg, int return_value);
72
73 #endif /* __LOUDGAME_H__ */