]> git.lizzy.rs Git - dragonblocks_alpha.git/blob - src/server.h
cee2383fa039401819571e6f7e268c3615733241
[dragonblocks_alpha.git] / src / server.h
1 #ifndef _SERVER_H_
2 #define _SERVER_H_
3
4 #include <pthread.h>
5 #include <netinet/in.h>
6 #include "clientcommands.h"
7 #include "servercommands.h"
8 #include "linkedlist.h"
9 #include "map.h"
10 #include "network.h"
11
12 typedef struct
13 {
14         int sockfd;
15         Map *map;
16         LinkedList clients;
17 } Server;
18
19 typedef struct Client
20 {
21         int fd;
22         char *name;
23         char *address;
24         Server *server;
25         ClientState state;
26         pthread_mutex_t mtx;
27 } Client;
28
29 typedef enum
30 {
31         DISCO_NO_REMOVE = 0x01,
32         DISCO_NO_SEND = 0x02,
33         DISCO_NO_MESSAGE = 0x04,
34 } DiscoFlag;
35
36 char *server_get_client_name(Client *client);
37 void server_disconnect_client(Client *client, int flags, const char *detail);
38 void server_shutdown(Server *srv);
39
40 #endif