summaryrefslogtreecommitdiff
path: root/minecproxy/server.h
blob: 41aaf41052945b4928123e6bb9867144cb2afaa1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef fooserverhfoo
#define fooserverhfoo

#include "shared/config-parser.h"

/* clang-format off */
enum server_state {
	SERVER_STATE_INIT	= 0,
	SERVER_STATE_CFG_OK	= 1,
	SERVER_STATE_RUNNING	= 2,
	SERVER_STATE_STOPPED	= 3,
	SERVER_STATE_DEAD	= 4,
};
/* clang-format on */

struct server {
	struct server_config scfg;
	struct list_head listenings;
	struct list_head proxys;
	enum server_state state;

	/* For calling external start/stop executables */
	struct uring_task exec_task;

	/* For rcon connections */
	struct connection rcon_conn;
	struct uring_task rcon_task;
	struct uring_task_buf rcon_tbuf;

	/* For announce messages */
	struct uring_task ann_task;
	struct uring_task_buf ann_buf;

	/* For checking idle status */
	struct uring_task idle_task;
	struct connection idle_conn;
	struct uring_task_buf idle_buf;
	unsigned idle_count;

	/* For reading config files */
	struct uring_task task;
	struct uring_task_buf tbuf;

	struct list_head list;
};

void server_refdump(struct server *server);

void server_delete(struct server *server);

void server_delete_by_filename(const char *filename);

bool server_start(struct server *server);

bool server_stop(struct server *server);

void server_update_active_players(struct server *server, int count);

bool server_idle_check(struct server *server);

bool server_announce(struct server *server, int fd);

bool server_commit(struct server *server);

struct server *server_new(const char *name);

#endif