00001 /* $Id: player_network.hpp 52533 2012-01-07 02:35:17Z shadowmaster $ */ 00002 /* 00003 Copyright (C) 2003 - 2012 by David White <dave@whitevine.net> 00004 Copyright (C) 2009 - 2012 by Tomasz Sniatowski <kailoran@gmail.com> 00005 Part of the Battle for Wesnoth Project http://www.wesnoth.org/ 00006 00007 This program is free software; you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License as published by 00009 the Free Software Foundation; either version 2 of the License, or 00010 (at your option) any later version. 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY. 00013 00014 See the COPYING file for more details. 00015 */ 00016 00017 #ifndef SERVER_PLAYER_NETWORK_HPP_INCLUDED 00018 #define SERVER_PLAYER_NETWORK_HPP_INCLUDED 00019 00020 #include "../network.hpp" 00021 #include "player.hpp" 00022 #include "simple_wml.hpp" 00023 00024 #include <boost/function.hpp> 00025 00026 namespace wesnothd { 00027 00028 namespace chat_message { 00029 /** 00030 * Function to ensure a text message is within the allowed length 00031 */ 00032 void truncate_message(const simple_wml::string_span& str, 00033 simple_wml::node& message); 00034 } // end chat_message namespace 00035 00036 typedef std::map<network::connection,player> player_map; 00037 typedef std::vector<network::connection> connection_vector; 00038 00039 /** 00040 * Send a wml document to a single player 00041 * @param data the document to send 00042 * @param sock the socket id to send to 00043 * @param packet_type the packet type, if empty the root node name is used 00044 */ 00045 bool send_to_one(simple_wml::document& data, 00046 const network::connection sock, 00047 std::string packet_type = ""); 00048 00049 /** 00050 * Send a wml document to a vector of players. More efficient than calling 00051 * send_to_one many times. 00052 * @param data the document to send 00053 * @param vec the vector of player socket ids to send to 00054 * @param exclude if nonzero, do not send to this player 00055 * @param packet_type the packet type, if empty the root node name is used 00056 */ 00057 void send_to_many(simple_wml::document& data, 00058 const connection_vector& vec, 00059 const network::connection exclude = 0, 00060 std::string packet_type = ""); 00061 /** 00062 * A more powerful version of send_to_many, allowing the use of a predicate 00063 * connection->bool. The document will be sent only to those sockets for which 00064 * the predicate evaluates to false. 00065 * @param data the document to send 00066 * @param vec the vector of player socket ids to send to 00067 * @param pred the predicate 00068 * @param exclude if nonzero, do not send to this player 00069 * @param packet_type the packet type, if empty the root node name is used 00070 */ 00071 void send_to_many(simple_wml::document& data, 00072 const connection_vector& vec, 00073 boost::function<bool (network::connection)> pred, 00074 const network::connection exclude = 0, 00075 std::string packet_type = ""); 00076 } //end namespace wesnothd 00077 00078 #endif
| Generated by doxygen 1.7.1 on Fri May 25 2012 01:03:09 for The Battle for Wesnoth | Gna! | Forum | Wiki | CIA | devdocs |