-
-
Notifications
You must be signed in to change notification settings - Fork 991
/
campaign_server.hpp
91 lines (68 loc) · 2.22 KB
/
campaign_server.hpp
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
Copyright (C) 2003 - 2014 by David White <dave@whitevine.net>
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
See the COPYING file for more details.
*/
#ifndef CAMPAIGN_SERVER_HPP_INCLUDED
#define CAMPAIGN_SERVER_HPP_INCLUDED
#include "campaign_server/blacklist.hpp"
#include "network.hpp"
#include "server/input_stream.hpp"
namespace campaignd {
/**
* Legacy add-ons server.
*/
class server : private boost::noncopyable
{
public:
explicit server(const std::string& cfg_file,
size_t min_threads = 10,
size_t max_threads = 0);
~server();
/**
* Runs the server request processing loop.
*/
void run();
private:
config cfg_;
const std::string cfg_file_;
bool read_only_;
int compress_level_; /**< Used for add-on archives. */
input_stream* input_; /**< Server control socket. */
std::map<std::string, std::string> hooks_;
std::string feedback_url_format_;
blacklist blacklist_;
std::string blacklist_file_;
const network::manager net_manager_;
const network::server_manager server_manager_;
/**
* Reads the server configuration from WML.
*
* @return The configured listening port number.
*/
int load_config();
/**
* Reads the add-ons upload blacklist from WML.
*/
void load_blacklist();
/**
* Fires a hook script.
*/
void fire(const std::string& hook, const std::string& addon);
/** Retrieves the contents of the [campaigns] WML node. */
const config& campaigns() const { return cfg_.child("campaigns"); }
/** Retrieves the contents of the [campaigns] WML node. */
config& campaigns() { return cfg_.child("campaigns"); }
/** Retrieves the contents of the [server_info] WML node. */
const config& server_info() const { return cfg_.child("server_info"); }
/** Retrieves the contents of the [server_info] WML node. */
config& server_info() { return cfg_.child("server_info"); }
};
} // end namespace campaignd
#endif