Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef SERVER_ROOM_HPP_INCLUDED
00017 #define SERVER_ROOM_HPP_INCLUDED
00018
00019 #include "../network.hpp"
00020 #include "player.hpp"
00021 #include "simple_wml.hpp"
00022
00023 namespace wesnothd {
00024
00025 typedef std::vector<network::connection> connection_vector;
00026 typedef std::map<network::connection,player> player_map;
00027 class game;
00028
00029
00030
00031
00032 class room {
00033 public:
00034
00035
00036
00037 room(const std::string& name);
00038
00039
00040
00041
00042 room(const config& cfg);
00043
00044
00045
00046
00047 void write(config& cfg) const;
00048
00049
00050
00051
00052 const std::string& name() const;
00053
00054
00055
00056
00057
00058 bool persistent() const;
00059
00060
00061
00062
00063 void set_persistent(bool v);
00064
00065
00066
00067
00068 bool logged() const;
00069
00070
00071
00072
00073 void set_logged(bool v);
00074
00075
00076
00077
00078 const std::string& topic() const;
00079
00080
00081
00082
00083 void set_topic(const std::string& v);
00084
00085
00086
00087
00088 size_t size() const {
00089 return members_.size();
00090 }
00091
00092
00093
00094
00095 bool empty() const {
00096 return members_.empty();
00097 }
00098
00099
00100
00101
00102 const std::vector<network::connection>& members() const {
00103 return members_;
00104 }
00105
00106
00107
00108
00109
00110 bool is_member(network::connection player) const {
00111 return std::find(members_.begin(), members_.end(), player) != members_.end();
00112 }
00113
00114
00115
00116
00117
00118 bool add_player(network::connection player);
00119
00120
00121
00122
00123 void remove_player(network::connection player);
00124
00125
00126
00127
00128 void process_message(simple_wml::document& data, const player_map::iterator user);
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138 void send_data(simple_wml::document& data, const network::connection exclude=0, std::string packet_type = "") const;
00139
00140
00141
00142
00143
00144
00145 void send_server_message_to_all(const char* message, network::connection exclude=0) const;
00146 void send_server_message_to_all(const std::string& message, network::connection exclude=0) const
00147 {
00148 send_server_message_to_all(message.c_str(), exclude);
00149 }
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160 void send_server_message(const char* message, network::connection sock,
00161 simple_wml::document* docptr = NULL) const;
00162
00163 void send_server_message(const std::string& message, network::connection sock,
00164 simple_wml::document* docptr = NULL) const
00165 {
00166 send_server_message(message.c_str(), sock, docptr);
00167 }
00168
00169
00170 private:
00171 std::string name_;
00172 connection_vector members_;
00173 bool persistent_;
00174 std::string topic_;
00175 bool logged_;
00176 };
00177
00178 }
00179
00180 #endif