Author: ilor
Date: Tue May 19 23:49:08 2009
New Revision: 35762
URL: http://svn.gna.org/viewcvs/wesnoth?rev=35762&view=rev
Log:
Add some doxy docs
Modified:
trunk/src/server/player_network.hpp
trunk/src/server/room.hpp
Modified: trunk/src/server/player_network.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/server/player_network.hpp?rev=35762&r1=35761&r2=35762&view=diff
==============================================================================
--- trunk/src/server/player_network.hpp (original)
+++ trunk/src/server/player_network.hpp Tue May 19 23:49:08 2009
@@ -24,6 +24,9 @@
namespace wesnothd {
namespace chat_message {
+ /**
+ * Function to ensure a text message is within the allowed length
+ */
void truncate_message(const simple_wml::string_span& str,
simple_wml::node& message);
} // end chat_message namespace
@@ -31,20 +34,47 @@
typedef std::map<network::connection,player> player_map;
typedef std::vector<network::connection> connection_vector;
-/** Convenience function for finding a user by name. */
+/** Convenience function for finding a user by name
+ * @param all_players map of all players
+ * @param name name of the player to look for
+ * @return an iterator pointing to the player, or to end() if the
+ * name was not found.
+ */
player_map::const_iterator find_user(const player_map& all_players,
const
simple_wml::string_span& name);
-
+/**
+ * Send a wml document to a single player
+ * @param data the document to send
+ * @param sock the socket id to send to
+ * @param packet_type the packet type, if empty the root node name is used
+ */
void send_to_one(simple_wml::document& data,
const network::connection sock,
std::string packet_type = "");
+/**
+ * Send a wml document to a vector of players. More efficient than calling
+ * send_to_one many times.
+ * @param data the document to send
+ * @param vec the vector of player socket ids to send to
+ * @param exclude if nonzero, do not send to this player
+ * @param packet_type the packet type, if empty the root node name is used
+ */
void send_to_many(simple_wml::document& data,
const connection_vector& vec,
const network::connection exclude = 0,
std::string packet_type = "");
-
+/**
+ * A more powerful version of send_to_many, allowing the use of a predicate
+ * connection->bool. The document will be sent only to those sockets for which
+ * the except_pred predicate evaluates to false.
+ * @param data the document to send
+ * @param vec the vector of player socket ids to send to
+ * @param except_pred a general exclusion predicate
+ * @param exclude if nonzero, do not send to this player
+ * @param packet_type the packet type, if empty the root node name is used
+ */
void send_to_many(simple_wml::document& data,
const connection_vector& vec,
boost::function<bool (network::connection)>
except_pred,
Modified: trunk/src/server/room.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/server/room.hpp?rev=35762&r1=35761&r2=35762&view=diff
==============================================================================
--- trunk/src/server/room.hpp (original)
+++ trunk/src/server/room.hpp Tue May 19 23:49:08 2009
@@ -25,8 +25,14 @@
class game;
+/**
+ * A room is a group of players that can communicate via messages.
+ */
class room {
public:
+ /**
+ * Construct a room
+ */
room();
/**
@@ -43,23 +49,63 @@
return members_;
}
+ /**
+ * Membership checker.
+ * @return true iif player is a member of this room
+ */
bool is_member(network::connection player) const {
return std::find(members_.begin(), members_.end(), player) !=
members_.end();
}
+ /**
+ * Joining the room
+ * @return true if the player was succesfully added
+ */
bool add_player(network::connection player);
+ /**
+ * Add all players from a game into this room
+ */
void add_players(const game& game);
+ /**
+ * Leaving the room
+ */
void remove_player(network::connection player);
+ /**
+ * Chat message processing
+ */
void process_message(simple_wml::document& data, const
player_map::iterator user);
-
+ /**
+ * Convenience function for sending a wml document to all (or all except
+ * one) members.
+ * @see send_to_many
+ * @param data the document to send
+ * @param exclude if nonzero, do not send to this player
+ * @param packet_type the packet type, if empty the root node name is
used
+ */
void send_data(simple_wml::document& data, const network::connection
exclude=0, std::string packet_type = "") const;
+ /**
+ * Send a text message to all members
+ * @param message the message text
+ * @param exclude if nonzero, do not send to this player
+ */
void send_server_message_to_all(const char* message,
network::connection exclude=0) const;
- void send_server_message(const char* message, network::connection sock,
simple_wml::document* docptr = NULL) 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.
+ * @param message the message text
+ * @param sock the socket to send the message to, if nonzero
+ * @param docptr the wml document to store the message in, if nonnull
+ */
+ void send_server_message(const char* message, network::connection sock,
+ simple_wml::document* docptr = NULL) const;
private:
connection_vector members_;
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits