A room is a group of players that can communicate via messages. More...
#include <room.hpp>
Public Member Functions | |
room (const std::string &name) | |
Construct a room with just a name and default settings. More... | |
room (const config &cfg) | |
Construct a room from WML. More... | |
void | write (config &cfg) const |
Write room info to a config. More... | |
const std::string & | name () const |
The name of this room. More... | |
bool | persistent () const |
Whether this room should be 'persistent', i.e. More... | |
void | set_persistent (bool v) |
Set the persistent flag for this room. More... | |
bool | logged () const |
Whether the room is logged (and might end up in e.g. More... | |
void | set_logged (bool v) |
Set the room's logged flag. More... | |
const std::string & | topic () const |
This room's topic/motd, sent to all joining players. More... | |
void | set_topic (const std::string &v) |
Set the topic for this room. More... | |
size_t | size () const |
Return the number of players in this room. More... | |
bool | empty () const |
Return true iif the room is empty. More... | |
const std::vector < network::connection > & | members () const |
Return the members of this room. More... | |
bool | is_member (network::connection player) const |
Membership checker. More... | |
bool | add_player (network::connection player) |
Joining the room. More... | |
void | remove_player (network::connection player) |
Leaving the room. More... | |
void | process_message (simple_wml::document &data, const player_map::iterator user) |
Chat message processing. More... | |
void | send_data (simple_wml::document &data, const network::connection exclude=0, std::string packet_type="") const |
Convenience function for sending a wml document to all (or all except one) members. More... | |
void | send_server_message_to_all (const char *message, network::connection exclude=0) const |
Send a text message to all members. More... | |
void | send_server_message_to_all (const std::string &message, network::connection exclude=0) const |
void | send_server_message (const char *message, network::connection sock, simple_wml::document *docptr=nullptr) const |
Prepare a text message and/or send it to a player. More... | |
void | send_server_message (const std::string &message, network::connection sock, simple_wml::document *docptr=nullptr) const |
Private Attributes | |
std::string | name_ |
connection_vector | members_ |
bool | persistent_ |
std::string | topic_ |
bool | logged_ |
A room is a group of players that can communicate via messages.
wesnothd::room::room | ( | const std::string & | name | ) |
wesnothd::room::room | ( | const config & | cfg | ) |
bool wesnothd::room::add_player | ( | network::connection | player | ) |
Joining the room.
Definition at line 91 of file room.cpp.
References ERR_ROOM, is_member(), and members_.
Referenced by wesnothd::room_manager::enter_lobby(), and wesnothd::room_manager::player_enters_room().
|
inline |
Return true iif the room is empty.
Definition at line 94 of file room.hpp.
References members_.
Referenced by wesnothd::room_manager::process_room_part().
|
inline |
Membership checker.
Definition at line 109 of file room.hpp.
References gui2::event::find(), and members_.
Referenced by add_player(), wesnothd::room_manager::in_lobby(), wesnothd::room_manager::player_enters_room(), and wesnothd::room_manager::require_member().
bool wesnothd::room::logged | ( | ) | const |
Whether the room is logged (and might end up in e.g.
the lobby bot
Definition at line 81 of file room.cpp.
References logged_.
Referenced by wesnothd::room_manager::process_message().
|
inline |
Return the members of this room.
Definition at line 101 of file room.hpp.
References members_.
Referenced by wesnothd::room_manager::fill_member_list(), wesnothd::room_manager::fill_room_list(), and send_data().
const std::string & wesnothd::room::name | ( | ) | const |
The name of this room.
Definition at line 56 of file room.cpp.
References name_.
Referenced by wesnothd::room_manager::fill_room_list(), wesnothd::room_manager::read_rooms(), and wesnothd::room_manager::store_player_rooms().
bool wesnothd::room::persistent | ( | ) | const |
Whether this room should be 'persistent', i.e.
not deleted when there are no players within and stored on disk if needed.
Definition at line 61 of file room.cpp.
References persistent_.
Referenced by wesnothd::room_manager::process_room_part(), wesnothd::room_manager::process_room_query(), and wesnothd::room_manager::write_rooms().
void wesnothd::room::process_message | ( | simple_wml::document & | data, |
const player_map::iterator | user | ||
) |
void wesnothd::room::remove_player | ( | network::connection | player | ) |
Leaving the room.
Definition at line 102 of file room.cpp.
References ERR_ROOM, gui2::event::find(), itor, and members_.
Referenced by wesnothd::room_manager::exit_lobby(), wesnothd::room_manager::player_exits_room(), and wesnothd::room_manager::remove_player().
void wesnothd::room::send_data | ( | simple_wml::document & | data, |
const network::connection | exclude = 0 , |
||
std::string | packet_type = "" |
||
) | const |
Convenience function for sending a wml document to all (or all except one) members.
data | the document to send |
exclude | if nonzero, do not send to this player |
packet_type | the packet type, if empty the root node name is used |
Definition at line 115 of file room.cpp.
References members().
Referenced by wesnothd::room_manager::process_message(), wesnothd::room_manager::process_room_join(), wesnothd::room_manager::process_room_part(), send_server_message_to_all(), and wesnothd::room_manager::unstore_player_rooms().
void wesnothd::room::send_server_message | ( | const char * | message, |
network::connection | sock, | ||
simple_wml::document * | docptr = nullptr |
||
) | const |
Prepare a text message and/or send it to a player.
If a nonzero sock is passed, the message is sent to this player. If a non-null pointer to a simple_wml::document is passed, the message is stored in that document.
message | the message text |
sock | the socket to send the message to, if nonzero |
docptr | the wml document to store the message in, if nonnull |
Definition at line 129 of file room.cpp.
References simple_wml::node::add_child(), game_logic::msg(), simple_wml::document::root(), simple_wml::node::set_attr(), and simple_wml::node::set_attr_dup().
Referenced by wesnothd::room_manager::get_create_room(), wesnothd::room_manager::player_enters_room(), wesnothd::room_manager::process_message(), wesnothd::room_manager::process_room_part(), wesnothd::room_manager::process_room_query(), wesnothd::room_manager::require_member(), wesnothd::room_manager::require_room(), send_server_message(), and send_server_message_to_all().
|
inline |
Definition at line 162 of file room.hpp.
References send_server_message().
void wesnothd::room::send_server_message_to_all | ( | const char * | message, |
network::connection | exclude = 0 |
||
) | const |
Send a text message to all members.
message | the message text |
exclude | if nonzero, do not send to this player |
Definition at line 122 of file room.cpp.
References send_data(), and send_server_message().
Referenced by send_server_message_to_all().
|
inline |
Definition at line 145 of file room.hpp.
References send_server_message_to_all().
void wesnothd::room::set_logged | ( | bool | v | ) |
Set the room's logged flag.
Definition at line 86 of file room.cpp.
References logged_.
Referenced by wesnothd::room_manager::process_room_query(), and wesnothd::room_manager::read_rooms().
void wesnothd::room::set_persistent | ( | bool | v | ) |
Set the persistent flag for this room.
Definition at line 66 of file room.cpp.
References persistent_.
Referenced by wesnothd::room_manager::process_room_query(), and wesnothd::room_manager::read_rooms().
void wesnothd::room::set_topic | ( | const std::string & | v | ) |
Set the topic for this room.
Definition at line 76 of file room.cpp.
References topic_.
Referenced by wesnothd::room_manager::process_room_query().
|
inline |
const std::string & wesnothd::room::topic | ( | ) | const |
This room's topic/motd, sent to all joining players.
Definition at line 71 of file room.cpp.
References topic_.
Referenced by wesnothd::room_manager::process_room_join(), wesnothd::room_manager::process_room_query(), and wesnothd::room_manager::unstore_player_rooms().
Write room info to a config.
Definition at line 48 of file room.cpp.
References logged_, name_, persistent_, and topic_.
Referenced by wesnothd::room_manager::write_rooms().
|
private |
Definition at line 174 of file room.hpp.
Referenced by logged(), set_logged(), and write().
|
private |
Definition at line 171 of file room.hpp.
Referenced by add_player(), empty(), is_member(), members(), remove_player(), and size().
|
private |
|
private |
Definition at line 172 of file room.hpp.
Referenced by persistent(), set_persistent(), and write().
|
private |
Definition at line 173 of file room.hpp.
Referenced by set_topic(), topic(), and write().