5 #include <netinet/in.h>
6 #include <dragontype/number.h>
7 #include <dragontype/list.h>
8 #include "client/client_commands.h"
9 #include "server/database.h"
10 #include "server/server_commands.h"
15 int sockfd; // TCP socket to accept new connections
16 pthread_rwlock_t clients_rwlck; // lock to protect client list
17 List clients; // Client * -> NULL map with all connected clients
18 pthread_rwlock_t players_rwlck; // lock to protect player list
19 List players; // char * -> Client * map with clients that have finished auth
22 u32 simulation_distance; // perimeter of the cube that players can see blocks in is simulation_distance * 2 + 1
23 } config; // configuration, ToDo: read from config file
28 int fd; // TCP socket for connection
29 pthread_mutex_t mtx; // mutex to protect socket
30 ClientState state; // state of the client (created, auth, active, disconnected)
31 char *address; // address string to use as identifier for log messages until auth is completed
32 char *name; // player name (must be unique)
33 Server *server; // pointer to server object (essentially the same for all clients)
34 pthread_t net_thread; // reciever thread ID
35 v3f64 pos; // player position
40 DISCO_NO_REMOVE = 0x01, // don't remove from client and player list (to save extra work on server shutdown)
41 DISCO_NO_SEND = 0x02, // don't notfiy client about the disconnect (if client sent disconnect themselves or the TCP connection died)
42 DISCO_NO_MESSAGE = 0x04, // don't log a message about the disconnect (used on server shutdown)
43 DISCO_NO_JOIN = 0x08, // don't wait for the reciever thread to finish (if TCP connection death was reported by reciever thread, the thread is already dead)
46 void server_disconnect_client(Client *client, int flags, const char *detail); // disconnect a client with various options an an optional detail message (flags: DiscoFlag bitmask)