Remove the 'gzipped' parameters from the network API.
ANA did not even implement binary WML.
This commit is contained in:
parent
3178d08d75
commit
9a508b5730
25 changed files with 136 additions and 182 deletions
|
@ -491,7 +491,7 @@ namespace {
|
|||
{
|
||||
config request_terms;
|
||||
request_terms.add_child("request_terms");
|
||||
network::send_data(request_terms, sock, true);
|
||||
network::send_data(request_terms, sock);
|
||||
config data;
|
||||
sock = network::receive_data(data,sock,5000);
|
||||
if(!sock) {
|
||||
|
@ -539,7 +539,7 @@ namespace {
|
|||
data.add_child("upload",cfg).add_child("data",addon_data);
|
||||
|
||||
LOG_NET << "uploading add-on...\n";
|
||||
network::send_data(data, sock, true);
|
||||
network::send_data(data, sock);
|
||||
|
||||
sock = dialogs::network_send_dialog(disp,_("Sending add-on"),data,sock);
|
||||
if(!sock) {
|
||||
|
@ -564,7 +564,7 @@ namespace {
|
|||
config data;
|
||||
data.add_child("delete",msg);
|
||||
|
||||
network::send_data(data, sock, true);
|
||||
network::send_data(data, sock);
|
||||
|
||||
sock = network::receive_data(data,sock,5000);
|
||||
if(!sock) {
|
||||
|
@ -588,7 +588,7 @@ namespace {
|
|||
// Proceed to download and install
|
||||
config request;
|
||||
request.add_child("request_campaign")["name"] = addon_id;
|
||||
network::send_data(request, sock, true);
|
||||
network::send_data(request, sock);
|
||||
|
||||
utils::string_map syms;
|
||||
syms["addon_title"] = addon_title;
|
||||
|
@ -1127,7 +1127,7 @@ namespace {
|
|||
|
||||
config cfg;
|
||||
cfg.add_child("request_campaign_list");
|
||||
network::send_data(cfg, sock, true);
|
||||
network::send_data(cfg, sock);
|
||||
network::connection res = dialogs::network_receive_dialog(disp, _("Requesting list of add-ons"), cfg, sock);
|
||||
if(!res) {
|
||||
return;
|
||||
|
|
|
@ -293,6 +293,7 @@ namespace {
|
|||
copying["contents"] = contents;
|
||||
|
||||
}
|
||||
/// @todo Check if this function has any purpose left
|
||||
void campaign_server::convert_binary_to_gzip()
|
||||
{
|
||||
if (!cfg_["converted_to_gzipped_data"].to_bool())
|
||||
|
@ -373,7 +374,6 @@ namespace {
|
|||
|
||||
if (!cfg_["control_socket"].empty())
|
||||
input_ = new input_stream(cfg_["control_socket"]);
|
||||
bool gzipped;
|
||||
network::connection sock = 0;
|
||||
for(int increment = 0; ; ++increment) {
|
||||
try {
|
||||
|
@ -400,10 +400,10 @@ namespace {
|
|||
}
|
||||
|
||||
config data;
|
||||
while((sock = network::receive_data(data, 0, &gzipped)) != network::null_connection) {
|
||||
while((sock = network::receive_data(data, 0)) != network::null_connection) {
|
||||
if (const config &req = data.child("request_campaign_list"))
|
||||
{
|
||||
LOG_CS << "sending campaign list to " << network::ip_address(sock) << (gzipped?" using gzip":"");
|
||||
LOG_CS << "sending campaign list to " << network::ip_address(sock) << " using gzip";
|
||||
time_t epoch = time(NULL);
|
||||
config campaign_list;
|
||||
campaign_list["timestamp"] = lexical_cast<std::string>(epoch);
|
||||
|
@ -453,27 +453,17 @@ namespace {
|
|||
|
||||
config response;
|
||||
response.add_child("campaigns",campaign_list);
|
||||
std::cerr << " size: " << (network::send_data(response, sock, gzipped)/1024) << "kb\n";
|
||||
std::cerr << " size: " << (network::send_data(response, sock)/1024) << "kb\n";
|
||||
}
|
||||
else if (const config &req = data.child("request_campaign"))
|
||||
{
|
||||
LOG_CS << "sending campaign '" << req["name"] << "' to " << network::ip_address(sock) << (gzipped?" using gzip":"");
|
||||
LOG_CS << "sending campaign '" << req["name"] << "' to " << network::ip_address(sock) << " using gzip";
|
||||
config &campaign = campaigns().find_child("campaign", "name", req["name"]);
|
||||
if (!campaign) {
|
||||
network::send_data(construct_error("Add-on '" + req["name"].str() + "'not found."), sock, gzipped);
|
||||
network::send_data(construct_error("Add-on '" + req["name"].str() + "'not found."), sock);
|
||||
} else {
|
||||
if (gzipped)
|
||||
{
|
||||
std::cerr << " size: " << (file_size(campaign["filename"])/1024) << "kb\n";
|
||||
network::send_file(campaign["filename"], sock);
|
||||
} else {
|
||||
scoped_istream stream = istream_file(campaign["filename"]);
|
||||
config cfg;
|
||||
read_gz(cfg, *stream);
|
||||
std::cerr << " size: " <<
|
||||
(network::send_data(cfg, sock, false)/1024)
|
||||
<< "kb\n";
|
||||
}
|
||||
std::cerr << " size: " << (file_size(campaign["filename"])/1024) << "kb\n";
|
||||
network::send_file(campaign["filename"], sock);
|
||||
int downloads = campaign["downloads"].to_int() + 1;
|
||||
campaign["downloads"] = downloads;
|
||||
}
|
||||
|
@ -482,7 +472,7 @@ namespace {
|
|||
else if (data.child("request_terms"))
|
||||
{
|
||||
LOG_CS << "sending terms " << network::ip_address(sock) << "\n";
|
||||
network::send_data(construct_message("All add-ons uploaded to this server must be licensed under the terms of the GNU General Public License (GPL). By uploading content to this server, you certify that you have the right to place the content under the conditions of the GPL, and choose to do so."), sock, gzipped);
|
||||
network::send_data(construct_message("All add-ons uploaded to this server must be licensed under the terms of the GNU General Public License (GPL). By uploading content to this server, you certify that you have the right to place the content under the conditions of the GPL, and choose to do so."), sock);
|
||||
LOG_CS << " Done\n";
|
||||
}
|
||||
else if (config &upload = data.child("upload"))
|
||||
|
@ -501,29 +491,29 @@ namespace {
|
|||
}
|
||||
if (!data) {
|
||||
LOG_CS << "Upload aborted - no add-on data.\n";
|
||||
network::send_data(construct_error("Add-on rejected: No add-on data was supplied."), sock, gzipped);
|
||||
network::send_data(construct_error("Add-on rejected: No add-on data was supplied."), sock);
|
||||
} else if (!addon_name_legal(upload["name"])) {
|
||||
LOG_CS << "Upload aborted - invalid add-on name.\n";
|
||||
network::send_data(construct_error("Add-on rejected: The name of the add-on is invalid."), sock, gzipped);
|
||||
network::send_data(construct_error("Add-on rejected: The name of the add-on is invalid."), sock);
|
||||
} else if (upload["title"].empty()) {
|
||||
LOG_CS << "Upload aborted - no add-on title specified.\n";
|
||||
network::send_data(construct_error("Add-on rejected: You did not specify the title of the add-on in the pbl file!"), sock, gzipped);
|
||||
network::send_data(construct_error("Add-on rejected: You did not specify the title of the add-on in the pbl file!"), sock);
|
||||
} else if (get_addon_type(upload["type"]) == ADDON_UNKNOWN) {
|
||||
LOG_CS << "Upload aborted - unknown add-on type specified.\n";
|
||||
network::send_data(construct_error("Add-on rejected: You did not specify a known type for the add-on in the pbl file! (See PblWML: wiki.wesnoth.org/PblWML)"), sock, gzipped);
|
||||
network::send_data(construct_error("Add-on rejected: You did not specify a known type for the add-on in the pbl file! (See PblWML: wiki.wesnoth.org/PblWML)"), sock);
|
||||
} else if (upload["author"].empty()) {
|
||||
LOG_CS << "Upload aborted - no add-on author specified.\n";
|
||||
network::send_data(construct_error("Add-on rejected: You did not specify the author(s) of the add-on in the pbl file!"), sock, gzipped);
|
||||
network::send_data(construct_error("Add-on rejected: You did not specify the author(s) of the add-on in the pbl file!"), sock);
|
||||
} else if (upload["version"].empty()) {
|
||||
LOG_CS << "Upload aborted - no add-on version specified.\n";
|
||||
network::send_data(construct_error("Add-on rejected: You did not specify the version of the add-on in the pbl file!"), sock, gzipped);
|
||||
network::send_data(construct_error("Add-on rejected: You did not specify the version of the add-on in the pbl file!"), sock);
|
||||
} else if (upload["description"].empty()) {
|
||||
LOG_CS << "Upload aborted - no add-on description specified.\n";
|
||||
network::send_data(construct_error("Add-on rejected: You did not specify a description of the add-on in the pbl file!"), sock, gzipped);
|
||||
network::send_data(construct_error("Add-on rejected: You did not specify a description of the add-on in the pbl file!"), sock);
|
||||
} else if (!check_names_legal(data)) {
|
||||
LOG_CS << "Upload aborted - invalid file names in add-on data.\n";
|
||||
network::send_data(construct_error("Add-on rejected: The add-on contains an illegal file or directory name."
|
||||
" File or directory names may not contain any of the following characters: '/ \\ : ~'"), sock, gzipped);
|
||||
" File or directory names may not contain any of the following characters: '/ \\ : ~'"), sock);
|
||||
} else if (campaign && (*campaign)["passphrase"].str() != upload["passphrase"]) {
|
||||
// the user password failed, now test for the master password, in master password
|
||||
// mode the upload behaves different since it's only intended to update translations.
|
||||
|
@ -564,11 +554,11 @@ namespace {
|
|||
file_size(filename));
|
||||
scoped_ostream cfgfile = ostream_file(file_);
|
||||
write(*cfgfile, cfg_);
|
||||
network::send_data(construct_message(message), sock, gzipped);
|
||||
network::send_data(construct_message(message), sock);
|
||||
|
||||
} else {
|
||||
LOG_CS << "Upload aborted - incorrect passphrase.\n";
|
||||
network::send_data(construct_error("Add-on rejected: The add-on already exists, and your passphrase was incorrect."), sock, gzipped);
|
||||
network::send_data(construct_error("Add-on rejected: The add-on already exists, and your passphrase was incorrect."), sock);
|
||||
}
|
||||
} else {
|
||||
LOG_CS << "Upload is owner upload.\n";
|
||||
|
@ -635,7 +625,7 @@ namespace {
|
|||
file_size(filename));
|
||||
scoped_ostream cfgfile = ostream_file(file_);
|
||||
write(*cfgfile, cfg_);
|
||||
network::send_data(construct_message(message), sock, gzipped);
|
||||
network::send_data(construct_message(message), sock);
|
||||
|
||||
fire("hook_post_upload", upload["name"]);
|
||||
}
|
||||
|
@ -645,7 +635,7 @@ namespace {
|
|||
LOG_CS << "deleting campaign '" << erase["name"] << "' requested from " << network::ip_address(sock) << "\n";
|
||||
const config &campaign = campaigns().find_child("campaign", "name", erase["name"]);
|
||||
if (!campaign) {
|
||||
network::send_data(construct_error("The add-on does not exist."), sock, gzipped);
|
||||
network::send_data(construct_error("The add-on does not exist."), sock);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -653,7 +643,7 @@ namespace {
|
|||
&& (campaigns()["master_password"].empty()
|
||||
|| campaigns()["master_password"] != erase["passphrase"]))
|
||||
{
|
||||
network::send_data(construct_error("The passphrase is incorrect."), sock, gzipped);
|
||||
network::send_data(construct_error("The passphrase is incorrect."), sock);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -672,7 +662,7 @@ namespace {
|
|||
}
|
||||
scoped_ostream cfgfile = ostream_file(file_);
|
||||
write(*cfgfile, cfg_);
|
||||
network::send_data(construct_message("Add-on deleted."), sock, gzipped);
|
||||
network::send_data(construct_message("Add-on deleted."), sock);
|
||||
|
||||
fire("hook_post_erase", erase["name"]);
|
||||
}
|
||||
|
@ -680,16 +670,16 @@ namespace {
|
|||
{
|
||||
config &campaign = campaigns().find_child("campaign", "name", cpass["name"]);
|
||||
if (!campaign) {
|
||||
network::send_data(construct_error("No add-on with that name exists."), sock, gzipped);
|
||||
network::send_data(construct_error("No add-on with that name exists."), sock);
|
||||
} else if (campaign["passphrase"] != cpass["passphrase"]) {
|
||||
network::send_data(construct_error("Your old passphrase was incorrect."), sock, gzipped);
|
||||
network::send_data(construct_error("Your old passphrase was incorrect."), sock);
|
||||
} else if (cpass["new_passphrase"].empty()) {
|
||||
network::send_data(construct_error("No new passphrase was supplied."), sock, gzipped);
|
||||
network::send_data(construct_error("No new passphrase was supplied."), sock);
|
||||
} else {
|
||||
campaign["passphrase"] = cpass["new_passphrase"];
|
||||
scoped_ostream cfgfile = ostream_file(file_);
|
||||
write(*cfgfile, cfg_);
|
||||
network::send_data(construct_message("Passphrase changed."), sock, gzipped);
|
||||
network::send_data(construct_message("Passphrase changed."), sock);
|
||||
}
|
||||
}
|
||||
else if (const config &cvalidate = data.child("validate_scripts"))
|
||||
|
@ -697,13 +687,13 @@ namespace {
|
|||
config &campaign = campaigns().find_child("campaign", "name", cvalidate["name"]);
|
||||
if (!campaign) {
|
||||
network::send_data(construct_error(
|
||||
"No add-on with that name exists."), sock, gzipped);
|
||||
"No add-on with that name exists."), sock);
|
||||
} else if (campaigns()["master_password"].empty()) {
|
||||
network::send_data(construct_error(
|
||||
"Sever does not allow scripts."), sock, gzipped);
|
||||
"Sever does not allow scripts."), sock);
|
||||
} else if (campaigns()["master_password"] != cvalidate["master_password"]) {
|
||||
network::send_data(construct_error(
|
||||
"Password was incorrect."), sock, gzipped);
|
||||
"Password was incorrect."), sock);
|
||||
} else {
|
||||
// Read the campaign from disk.
|
||||
config campaign_file;
|
||||
|
@ -722,9 +712,9 @@ namespace {
|
|||
file_size(campaign["filename"]));
|
||||
|
||||
network::send_data(construct_message("The following scripts have been validated: " +
|
||||
scripts), sock, gzipped);
|
||||
scripts), sock);
|
||||
} else {
|
||||
network::send_data(construct_message("No unchecked scripts found!"), sock, gzipped);
|
||||
network::send_data(construct_message("No unchecked scripts found!"), sock);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -123,7 +123,7 @@ bool lobby_info::process_gamelist_diff(const config &data)
|
|||
} catch(config::error& e) {
|
||||
ERR_LB << "Error while applying the gamelist diff: '"
|
||||
<< e.message << "' Getting a new gamelist.\n";
|
||||
network::send_data(config("refresh_lobby"), 0, true);
|
||||
network::send_data(config("refresh_lobby"), 0);
|
||||
return false;
|
||||
}
|
||||
DBG_LB << "postdiff " << dump_games_config(gamelist_.child("gamelist"));
|
||||
|
@ -135,7 +135,7 @@ bool lobby_info::process_gamelist_diff(const config &data)
|
|||
int game_id = c["id"];
|
||||
if (game_id == 0) {
|
||||
ERR_LB << "game with id 0 in gamelist config\n";
|
||||
network::send_data(config("refresh_lobby"), 0, true);
|
||||
network::send_data(config("refresh_lobby"), 0);
|
||||
return false;
|
||||
}
|
||||
game_info_map::iterator current_i = games_by_id_.find(game_id);
|
||||
|
@ -168,7 +168,7 @@ bool lobby_info::process_gamelist_diff(const config &data)
|
|||
} catch(config::error& e) {
|
||||
ERR_LB << "Error while applying the gamelist diff (2): '"
|
||||
<< e.message << "' Getting a new gamelist.\n";
|
||||
network::send_data(config("refresh_lobby"), 0, true);
|
||||
network::send_data(config("refresh_lobby"), 0);
|
||||
return false;
|
||||
}
|
||||
DBG_LB << "postclean " << dump_games_config(gamelist_.child("gamelist"));
|
||||
|
|
|
@ -199,7 +199,7 @@ void tlobby_main::send_chat_message(const std::string& message, bool /*allies_on
|
|||
data.add_child("message", msg);
|
||||
|
||||
add_chat_message(time(NULL), preferences::login(), 0, message); //local echo
|
||||
network::send_data(data, 0, true);
|
||||
network::send_data(data, 0);
|
||||
}
|
||||
|
||||
void tlobby_main::user_relation_changed(const std::string& /*name*/)
|
||||
|
@ -593,7 +593,7 @@ void tlobby_main::update_gamelist_diff()
|
|||
} else {
|
||||
if (list_i >= gamelistbox_->get_item_count()) {
|
||||
ERR_LB << "Ran out of listbox items -- triggering a full refresh\n";
|
||||
network::send_data(config("refresh_lobby"), 0, true);
|
||||
network::send_data(config("refresh_lobby"), 0);
|
||||
return;
|
||||
}
|
||||
if (list_i + list_rows_deleted >= gamelist_id_at_row_.size()) {
|
||||
|
@ -601,14 +601,14 @@ void tlobby_main::update_gamelist_diff()
|
|||
<< list_i << " + " << list_rows_deleted
|
||||
<< " >= " << gamelist_id_at_row_.size()
|
||||
<< " -- triggering a full refresh\n";
|
||||
network::send_data(config("refresh_lobby"), 0, true);
|
||||
network::send_data(config("refresh_lobby"), 0);
|
||||
return;
|
||||
}
|
||||
int listbox_game_id = gamelist_id_at_row_[list_i + list_rows_deleted];
|
||||
if (game.id != listbox_game_id) {
|
||||
ERR_LB << "Listbox game id does not match expected id "
|
||||
<< listbox_game_id << " " << game.id << " (row " << list_i << ")\n";
|
||||
network::send_data(config("refresh_lobby"), 0, true);
|
||||
network::send_data(config("refresh_lobby"), 0);
|
||||
return;
|
||||
}
|
||||
if (game.display_status == game_info::UPDATED) {
|
||||
|
@ -1285,7 +1285,7 @@ void tlobby_main::close_window(size_t idx)
|
|||
msg["room"] = t.name;
|
||||
msg["player"] = preferences::login();
|
||||
data.add_child("room_part", msg);
|
||||
network::send_data(data, 0, true);
|
||||
network::send_data(data, 0);
|
||||
}
|
||||
if (active_window_ == open_windows_.size() - 1) {
|
||||
active_window_--;
|
||||
|
@ -1576,7 +1576,7 @@ bool tlobby_main::do_game_join(int idx, bool observe)
|
|||
join["password"] = password;
|
||||
}
|
||||
}
|
||||
network::send_data(response, 0, true);
|
||||
network::send_data(response, 0);
|
||||
if (observe && game.started) {
|
||||
playmp_controller::set_replay_last_turn(game.current_turn);
|
||||
}
|
||||
|
@ -1625,7 +1625,7 @@ void tlobby_main::create_button_callback(gui2::twindow& window)
|
|||
|
||||
void tlobby_main::refresh_button_callback(gui2::twindow& /*window*/)
|
||||
{
|
||||
network::send_data(config("refresh_lobby"), 0, true);
|
||||
network::send_data(config("refresh_lobby"), 0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1641,7 +1641,7 @@ void tlobby_main::show_preferences_button_callback(gui2::twindow& window)
|
|||
*/
|
||||
window.invalidate_layout();
|
||||
|
||||
network::send_data(config("refresh_lobby"), 0, true);
|
||||
network::send_data(config("refresh_lobby"), 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1771,7 +1771,7 @@ void tlobby_main::user_dialog_callback(user_info* info)
|
|||
//update_gamelist();
|
||||
delay_playerlist_update_ = false;
|
||||
player_list_dirty_ = true;
|
||||
network::send_data(config("refresh_lobby"), 0, true);
|
||||
network::send_data(config("refresh_lobby"), 0);
|
||||
}
|
||||
|
||||
void tlobby_main::skip_replay_changed_callback(twidget* w)
|
||||
|
|
|
@ -2680,7 +2680,7 @@ void chat_handler::send_command(const std::string& cmd, const std::string& args
|
|||
} else if (cmd == "part") {
|
||||
data.add_child("room_part")["room"] = args;
|
||||
}
|
||||
network::send_data(data, 0, true);
|
||||
network::send_data(data, 0);
|
||||
}
|
||||
|
||||
void chat_handler::do_speak(const std::string& message, bool allies_only)
|
||||
|
@ -2714,7 +2714,7 @@ void chat_handler::send_whisper(const std::string& receiver, const std::string&
|
|||
cwhisper["message"] = message;
|
||||
cwhisper["sender"] = preferences::login();
|
||||
data.add_child("whisper", cwhisper);
|
||||
network::send_data(data, 0, true);
|
||||
network::send_data(data, 0);
|
||||
}
|
||||
|
||||
void chat_handler::add_whisper_sent(const std::string& receiver, const std::string& message)
|
||||
|
@ -2739,7 +2739,7 @@ void chat_handler::send_chat_room_message(const std::string& room,
|
|||
cmsg["message"] = message;
|
||||
cmsg["sender"] = preferences::login();
|
||||
data.add_child("message", cmsg);
|
||||
network::send_data(data, 0, true);
|
||||
network::send_data(data, 0);
|
||||
}
|
||||
|
||||
void chat_handler::add_chat_room_message_sent(const std::string &room, const std::string &message)
|
||||
|
@ -2775,7 +2775,7 @@ void chat_command_handler::do_room_query_noarg()
|
|||
config data;
|
||||
config& q = data.add_child("room_query");
|
||||
q.add_child(get_cmd());
|
||||
network::send_data(data, 0, true);
|
||||
network::send_data(data, 0);
|
||||
}
|
||||
|
||||
void chat_command_handler::do_room_query()
|
||||
|
@ -2785,7 +2785,7 @@ void chat_command_handler::do_room_query()
|
|||
config& q = data.add_child("room_query");
|
||||
q["room"] = get_arg(1);
|
||||
q.add_child(get_cmd());
|
||||
network::send_data(data, 0, true);
|
||||
network::send_data(data, 0);
|
||||
}
|
||||
|
||||
void chat_command_handler::do_gen_room_query()
|
||||
|
@ -2796,7 +2796,7 @@ void chat_command_handler::do_gen_room_query()
|
|||
q["room"] = get_arg(1);
|
||||
config& c = q.add_child(get_arg(2));
|
||||
c["value"] = get_data(3);
|
||||
network::send_data(data, 0, true);
|
||||
network::send_data(data, 0);
|
||||
}
|
||||
|
||||
void chat_command_handler::do_whisper()
|
||||
|
@ -2914,7 +2914,7 @@ void chat_command_handler::do_register() {
|
|||
}
|
||||
print(_("nick registration"), msg);
|
||||
|
||||
network::send_data(data, 0, true);
|
||||
network::send_data(data, 0);
|
||||
}
|
||||
|
||||
void chat_command_handler::do_drop() {
|
||||
|
@ -2925,7 +2925,7 @@ void chat_command_handler::do_drop() {
|
|||
|
||||
print(_("nick registration"), _("dropping your username"));
|
||||
|
||||
network::send_data(data, 0, true);
|
||||
network::send_data(data, 0);
|
||||
}
|
||||
|
||||
void chat_command_handler::do_set() {
|
||||
|
@ -2943,7 +2943,7 @@ void chat_command_handler::do_set() {
|
|||
symbols["value"] = get_arg(2);
|
||||
print(_("nick registration"), VGETTEXT("setting $var to $value", symbols));
|
||||
|
||||
network::send_data(data, 0, true);
|
||||
network::send_data(data, 0);
|
||||
}
|
||||
|
||||
void chat_command_handler::do_info() {
|
||||
|
@ -2957,7 +2957,7 @@ void chat_command_handler::do_info() {
|
|||
symbols["nick"] = get_arg(1);
|
||||
print(_("nick registration"), VGETTEXT("requesting information for user $nick", symbols));
|
||||
|
||||
network::send_data(data, 0, true);
|
||||
network::send_data(data, 0);
|
||||
}
|
||||
|
||||
void chat_command_handler::do_details() {
|
||||
|
@ -2966,7 +2966,7 @@ void chat_command_handler::do_details() {
|
|||
config& nickserv = data.add_child("nickserv");
|
||||
nickserv.add_child("details");
|
||||
|
||||
network::send_data(data, 0, true);
|
||||
network::send_data(data, 0);
|
||||
}
|
||||
|
||||
void menu_handler::send_chat_message(const std::string& message, bool allies_only)
|
||||
|
@ -3632,7 +3632,7 @@ void menu_handler::change_controller(const std::string& side, const std::string&
|
|||
config& change = cfg.add_child("change_controller");
|
||||
change["side"] = side;
|
||||
change["controller"] = controller;
|
||||
network::send_data(cfg, 0, true);
|
||||
network::send_data(cfg, 0);
|
||||
}
|
||||
|
||||
void menu_handler::change_side_controller(const std::string& side, const std::string& player, bool own_side)
|
||||
|
@ -3646,7 +3646,7 @@ void menu_handler::change_side_controller(const std::string& side, const std::st
|
|||
change["own_side"] = true;
|
||||
}
|
||||
|
||||
network::send_data(cfg, 0, true);
|
||||
network::send_data(cfg, 0);
|
||||
}
|
||||
} // end namespace events
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ public:
|
|||
LOG_NW << "sending leave_game\n";
|
||||
config cfg;
|
||||
cfg.add_child("leave_game");
|
||||
network::send_data(cfg, 0, true);
|
||||
network::send_data(cfg, 0);
|
||||
LOG_NW << "sent leave_game\n";
|
||||
}
|
||||
};
|
||||
|
@ -185,7 +185,7 @@ static server_type open_connection(game_display& disp, const std::string& origin
|
|||
config res;
|
||||
cfg["version"] = game_config::version;
|
||||
res.add_child("version", cfg);
|
||||
network::send_data(res, 0, true);
|
||||
network::send_data(res, 0);
|
||||
}
|
||||
|
||||
//if we got a direction to login
|
||||
|
@ -212,7 +212,7 @@ static server_type open_connection(game_display& disp, const std::string& origin
|
|||
// server to optimize ping frequency as needed.
|
||||
sp["selective_ping"] = true;
|
||||
}
|
||||
network::send_data(response, 0, true);
|
||||
network::send_data(response, 0);
|
||||
|
||||
// Get response for our login request...
|
||||
network::connection data_res = network::receive_data(data, 0, 3000);
|
||||
|
@ -273,7 +273,7 @@ static server_type open_connection(game_display& disp, const std::string& origin
|
|||
sp["password_reminder"] = password_reminder;
|
||||
|
||||
// Once again send our request...
|
||||
network::send_data(response, 0, true);
|
||||
network::send_data(response, 0);
|
||||
|
||||
network::connection data_res = network::receive_data(data, 0, 3000);
|
||||
if(!data_res) {
|
||||
|
@ -463,7 +463,7 @@ static void enter_connect_mode(game_display& disp, const config& game_config,
|
|||
break;
|
||||
case mp::ui::QUIT:
|
||||
default:
|
||||
network::send_data(config("refresh_lobby"), 0, true);
|
||||
network::send_data(config("refresh_lobby"), 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -476,7 +476,7 @@ static void enter_create_mode(game_display& disp, const config& game_config, mp:
|
|||
|
||||
dlg.show(disp.video());
|
||||
|
||||
network::send_data(config("refresh_lobby"), 0, true);
|
||||
network::send_data(config("refresh_lobby"), 0);
|
||||
} else {
|
||||
|
||||
mp::ui::result res;
|
||||
|
@ -498,7 +498,7 @@ static void enter_create_mode(game_display& disp, const config& game_config, mp:
|
|||
case mp::ui::QUIT:
|
||||
default:
|
||||
//update lobby content
|
||||
network::send_data(config("refresh_lobby"), 0, true);
|
||||
network::send_data(config("refresh_lobby"), 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -586,7 +586,7 @@ static void enter_lobby_mode(game_display& disp, const config& game_config, mp::
|
|||
gui2::show_error_message(disp.video(), error.message);
|
||||
}
|
||||
//update lobby content
|
||||
network::send_data(config("refresh_lobby"), 0, true);
|
||||
network::send_data(config("refresh_lobby"), 0);
|
||||
}
|
||||
break;
|
||||
case mp::ui::OBSERVE:
|
||||
|
@ -599,7 +599,7 @@ static void enter_lobby_mode(game_display& disp, const config& game_config, mp::
|
|||
}
|
||||
// update lobby content unconditionally because we might have left only after the
|
||||
// game ended in which case we ignored the gamelist and need to request it again
|
||||
network::send_data(config("refresh_lobby"), 0, true);
|
||||
network::send_data(config("refresh_lobby"), 0);
|
||||
break;
|
||||
case mp::ui::CREATE:
|
||||
try {
|
||||
|
@ -608,7 +608,7 @@ static void enter_lobby_mode(game_display& disp, const config& game_config, mp::
|
|||
if (!error.message.empty())
|
||||
gui2::show_error_message(disp.video(), error.message);
|
||||
//update lobby content
|
||||
network::send_data(config("refresh_lobby"), 0, true);
|
||||
network::send_data(config("refresh_lobby"), 0);
|
||||
}
|
||||
break;
|
||||
case mp::ui::QUIT:
|
||||
|
@ -617,7 +617,7 @@ static void enter_lobby_mode(game_display& disp, const config& game_config, mp::
|
|||
{
|
||||
do_preferences_dialog(disp, game_config);
|
||||
//update lobby content
|
||||
network::send_data(config("refresh_lobby"), 0, true);
|
||||
network::send_data(config("refresh_lobby"), 0);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -1046,7 +1046,7 @@ connect::connect(game_display& disp, const config& game_config,
|
|||
}
|
||||
}
|
||||
create_game["human_sides"] = lexical_cast<std::string>(human_sides);*/
|
||||
network::send_data(response, 0, true);
|
||||
network::send_data(response, 0);
|
||||
|
||||
// Adds the current user as default user.
|
||||
users_.push_back(connected_user(preferences::login(), CNTR_LOCAL, 0));
|
||||
|
@ -1076,7 +1076,7 @@ connect::connect(game_display& disp, const config& game_config,
|
|||
update_playerlist_state(true);
|
||||
|
||||
// If we are connected, send data to the connected host
|
||||
network::send_data(level_, 0, true);
|
||||
network::send_data(level_, 0);
|
||||
}
|
||||
|
||||
void connect::process_event()
|
||||
|
@ -1120,7 +1120,7 @@ void connect::process_event()
|
|||
if(network::nconnections() > 0) {
|
||||
config cfg;
|
||||
cfg.add_child("leave_game");
|
||||
network::send_data(cfg, 0, true);
|
||||
network::send_data(cfg, 0);
|
||||
}
|
||||
|
||||
set_result(QUIT);
|
||||
|
@ -1156,14 +1156,14 @@ void connect::start_game()
|
|||
// Make other clients not show the results of resolve_random().
|
||||
config lock;
|
||||
lock.add_child("stop_updates");
|
||||
network::send_data(lock, 0, true);
|
||||
network::send_data(lock, 0);
|
||||
update_and_send_diff(true);
|
||||
|
||||
// Build the gamestate object after updating the level
|
||||
|
||||
level_to_gamestate(level_, state_);
|
||||
|
||||
network::send_data(config("start_game"), 0, true);
|
||||
network::send_data(config("start_game"), 0);
|
||||
}
|
||||
|
||||
void connect::hide_children(bool hide)
|
||||
|
@ -1221,7 +1221,7 @@ void connect::process_network_data(const config& data, const network::connection
|
|||
if(name.empty()) {
|
||||
config response;
|
||||
response["failed"] = true;
|
||||
network::send_data(response, sock, true);
|
||||
network::send_data(response, sock);
|
||||
ERR_CF << "ERROR: No username provided with the side.\n";
|
||||
return;
|
||||
}
|
||||
|
@ -1236,13 +1236,13 @@ void connect::process_network_data(const config& data, const network::connection
|
|||
config response;
|
||||
response["failed"] = true;
|
||||
response["message"] = "The nick '" + name + "' is already in use.";
|
||||
network::send_data(response, sock, true);
|
||||
network::send_data(response, sock);
|
||||
return;
|
||||
} else {
|
||||
users_.erase(player);
|
||||
config observer_quit;
|
||||
observer_quit.add_child("observer_quit")["name"] = name;
|
||||
network::send_data(observer_quit, 0, true);
|
||||
network::send_data(observer_quit, 0);
|
||||
update_user_combos();
|
||||
}
|
||||
}
|
||||
|
@ -1264,12 +1264,12 @@ void connect::process_network_data(const config& data, const network::connection
|
|||
if(itor == sides_.end()) {
|
||||
config response;
|
||||
response["failed"] = true;
|
||||
network::send_data(response, sock, true);
|
||||
network::send_data(response, sock);
|
||||
config kick;
|
||||
kick["username"] = data["name"];
|
||||
config res;
|
||||
res.add_child("kick", kick);
|
||||
network::send_data(res, 0, true);
|
||||
network::send_data(res, 0);
|
||||
update_user_combos();
|
||||
update_and_send_diff();
|
||||
ERR_CF << "ERROR: Couldn't assign a side to '" << name << "'\n";
|
||||
|
@ -1298,7 +1298,7 @@ void connect::process_network_data(const config& data, const network::connection
|
|||
ERR_CF << "tried to take illegal side: " << side_taken << '\n';
|
||||
config response;
|
||||
response["failed"] = true;
|
||||
network::send_data(response, sock, true);
|
||||
network::send_data(response, sock);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1402,9 +1402,9 @@ void connect::process_network_connection(const network::connection sock)
|
|||
{
|
||||
ui::process_network_connection(sock);
|
||||
|
||||
network::send_data(config("join_game"), 0, true);
|
||||
network::send_data(config("join_game"), 0);
|
||||
|
||||
network::send_data(level_, sock, true);
|
||||
network::send_data(level_, sock);
|
||||
}
|
||||
|
||||
void connect::layout_children(const SDL_Rect& rect)
|
||||
|
@ -1685,7 +1685,7 @@ void connect::update_and_send_diff(bool update_time_of_day)
|
|||
if (!diff.empty()) {
|
||||
config scenario_diff;
|
||||
scenario_diff.add_child("scenario_diff", diff);
|
||||
network::send_data(scenario_diff, 0, true);
|
||||
network::send_data(scenario_diff, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -916,7 +916,7 @@ void lobby::process_event()
|
|||
if(!password.empty()) {
|
||||
join["password"] = password;
|
||||
}
|
||||
network::send_data(response, 0, true);
|
||||
network::send_data(response, 0);
|
||||
|
||||
if(observe) {
|
||||
if (game.started){
|
||||
|
|
|
@ -465,7 +465,7 @@ void ui::handle_event(const SDL_Event& event)
|
|||
//if the dialog has been open for a long time, refresh the lobby
|
||||
config request;
|
||||
request.add_child("refresh_lobby");
|
||||
network::send_data(request, 0, true);
|
||||
network::send_data(request, 0);
|
||||
}
|
||||
}
|
||||
if(users_menu_.selection() > 0 // -1 indicates an invalid selection
|
||||
|
@ -489,7 +489,7 @@ void ui::send_chat_message(const std::string& message, bool /*allies_only*/)
|
|||
data.add_child("message", msg);
|
||||
|
||||
add_chat_message(time(NULL), preferences::login(),0, message); //local echo
|
||||
network::send_data(data, 0, true);
|
||||
network::send_data(data, 0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -575,7 +575,7 @@ void ui::process_network_data(const config& data, const network::connection /*so
|
|||
} catch(config::error& e) {
|
||||
ERR_CF << "Error while applying the gamelist diff: '"
|
||||
<< e.message << "' Getting a new gamelist.\n";
|
||||
network::send_data(config("refresh_lobby"), 0, true);
|
||||
network::send_data(config("refresh_lobby"), 0);
|
||||
}
|
||||
gamelist_refresh_ = true;
|
||||
}
|
||||
|
|
|
@ -316,7 +316,7 @@ void wait::join_game(bool observe)
|
|||
change["faction"] = faction_choice;
|
||||
change["leader"] = leader_choice;
|
||||
change["gender"] = gender_choice;
|
||||
network::send_data(faction, 0, true);
|
||||
network::send_data(faction, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -707,7 +707,7 @@ connection receive_data(config& cfg, connection connection_num, unsigned int tim
|
|||
return 0;
|
||||
}
|
||||
|
||||
connection receive_data(config& cfg, connection connection_num, bool* gzipped, bandwidth_in_ptr* bandwidth_in)
|
||||
connection receive_data(config& cfg, connection connection_num, bandwidth_in_ptr* bandwidth_in)
|
||||
{
|
||||
if(!socket_set) {
|
||||
return 0;
|
||||
|
@ -767,7 +767,7 @@ connection receive_data(config& cfg, connection connection_num, bool* gzipped, b
|
|||
{
|
||||
bandwidth_in = &temp;
|
||||
}
|
||||
sock = network_worker_pool::get_received_data(sock,cfg, gzipped, *bandwidth_in);
|
||||
sock = network_worker_pool::get_received_data(sock,cfg, *bandwidth_in);
|
||||
if (sock == NULL) {
|
||||
if (!is_server() && last_ping != 0 && ping_timeout != 0)
|
||||
{
|
||||
|
@ -1053,12 +1053,7 @@ void send_file(const std::string& filename, connection connection_num, const std
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo Note the gzipped parameter should be removed later, we want to send
|
||||
* all data gzipped. This can be done once the campaign server is also updated
|
||||
* to work with gzipped data.
|
||||
*/
|
||||
size_t send_data(const config& cfg, connection connection_num, const bool gzipped, const std::string& packet_type)
|
||||
size_t send_data(const config& cfg, connection connection_num, const std::string& packet_type)
|
||||
{
|
||||
DBG_NW << "in send_data()...\n";
|
||||
|
||||
|
@ -1077,7 +1072,7 @@ size_t send_data(const config& cfg, connection connection_num, const bool gzippe
|
|||
for(sockets_list::const_iterator i = sockets.begin();
|
||||
i != sockets.end(); ++i) {
|
||||
DBG_NW << "server socket: " << server_socket << "\ncurrent socket: " << *i << "\n";
|
||||
size = send_data(cfg,*i, gzipped, packet_type);
|
||||
size = send_data(cfg,*i, packet_type);
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
@ -1090,7 +1085,7 @@ size_t send_data(const config& cfg, connection connection_num, const bool gzippe
|
|||
}
|
||||
|
||||
LOG_NW << "SENDING to: " << connection_num << ": " << cfg;
|
||||
return network_worker_pool::queue_data(info->second.sock, cfg, gzipped, packet_type);
|
||||
return network_worker_pool::queue_data(info->second.sock, cfg, packet_type);
|
||||
}
|
||||
|
||||
void send_raw_data(const char* buf, int len, connection connection_num, const std::string& packet_type)
|
||||
|
@ -1128,15 +1123,14 @@ void process_send_queue(connection, size_t)
|
|||
check_error();
|
||||
}
|
||||
|
||||
/** @todo Note the gzipped parameter should be removed later. */
|
||||
void send_data_all_except(const config& cfg, connection connection_num, const bool gzipped, const std::string& packet_type)
|
||||
void send_data_all_except(const config& cfg, connection connection_num, const std::string& packet_type)
|
||||
{
|
||||
for(sockets_list::const_iterator i = sockets.begin(); i != sockets.end(); ++i) {
|
||||
if(*i == connection_num) {
|
||||
continue;
|
||||
}
|
||||
|
||||
send_data(cfg,*i, gzipped, packet_type);
|
||||
send_data(cfg,*i, packet_type);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -217,7 +217,7 @@ typedef boost::shared_ptr<bandwidth_in> bandwidth_in_ptr;
|
|||
*
|
||||
* @throw error If an error occurred.
|
||||
*/
|
||||
connection receive_data(config& cfg, connection connection_num=0, bool* gzipped = 0, bandwidth_in_ptr* b = 0);
|
||||
connection receive_data(config& cfg, connection connection_num=0, bandwidth_in_ptr* b = 0);
|
||||
connection receive_data(config& cfg, connection connection_num, unsigned int timeout, bandwidth_in_ptr* b = 0);
|
||||
connection receive_data(std::vector<char>& buf, bandwidth_in_ptr* = 0);
|
||||
|
||||
|
@ -229,8 +229,8 @@ void send_file(const std::string&, connection, const std::string& packet_type =
|
|||
*
|
||||
* @throw error
|
||||
*/
|
||||
size_t send_data(const config& cfg, connection connection_num /*= 0*/,
|
||||
const bool gzipped, const std::string& packet_type = "unknown");
|
||||
size_t send_data(const config& cfg, connection connection_num = 0,
|
||||
const std::string& packet_type = "unknown");
|
||||
|
||||
void send_raw_data(const char* buf, int len, connection connection_num,
|
||||
const std::string& packet_type = "unknown");
|
||||
|
@ -244,7 +244,7 @@ void process_send_queue(connection connection_num=0, size_t max_size=0);
|
|||
|
||||
/** Function to send data to all peers except 'connection_num'. */
|
||||
void send_data_all_except(const config& cfg, connection connection_num,
|
||||
const bool gzipped, const std::string& packet_type = "unknown");
|
||||
const std::string& packet_type = "unknown");
|
||||
|
||||
/** Function to get the remote ip address of a socket. */
|
||||
std::string ip_address(connection connection_num);
|
||||
|
|
|
@ -242,7 +242,6 @@ namespace network {
|
|||
|
||||
connection receive_data(config& cfg,
|
||||
connection connection_num,
|
||||
bool* /*gzipped*/,
|
||||
bandwidth_in_ptr* bandwidth_in) // TODO: use this pointer
|
||||
{
|
||||
// <- just call the previous version without timeouts
|
||||
|
@ -331,23 +330,17 @@ namespace network {
|
|||
throw std::runtime_error("TODO:Not implemented send_file");
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo Note the gzipped parameter should be removed later, we want to send
|
||||
* all data gzipped. This can be done once the campaign server is also updated
|
||||
* to work with gzipped data.
|
||||
*/
|
||||
size_t send_data(const config& cfg,
|
||||
connection connection_num,
|
||||
const bool gzipped,
|
||||
const std::string& /*packet_type*/)
|
||||
{
|
||||
if(cfg.empty())
|
||||
return 0;
|
||||
|
||||
if( connection_num == 0 )
|
||||
return ana_manager.send_all( cfg, gzipped );
|
||||
return ana_manager.send_all( cfg );
|
||||
else
|
||||
return ana_manager.send( connection_num, cfg, gzipped );
|
||||
return ana_manager.send( connection_num, cfg );
|
||||
}
|
||||
|
||||
void send_raw_data(const char* buf,
|
||||
|
@ -363,10 +356,8 @@ namespace network {
|
|||
ana_manager.throw_if_pending_disconnection();
|
||||
}
|
||||
|
||||
/** @todo Note the gzipped parameter should be removed later. */
|
||||
void send_data_all_except(const config& cfg,
|
||||
connection connection_num,
|
||||
const bool /*gzipped*/,
|
||||
const std::string& /*packet_type*/)
|
||||
{
|
||||
ana_manager.send_all_except(cfg, connection_num);
|
||||
|
|
|
@ -873,7 +873,7 @@ void ana_network_manager::read_config( const ana::read_buffer& buffer, config& c
|
|||
read_gz(cfg, input);
|
||||
}
|
||||
|
||||
size_t ana_network_manager::send_all( const config& cfg, bool /*zipped*/ )
|
||||
size_t ana_network_manager::send_all( const config& cfg )
|
||||
{
|
||||
const std::string output_string = compress_config(cfg);
|
||||
|
||||
|
@ -902,12 +902,8 @@ size_t ana_network_manager::send_all( const config& cfg, bool /*zipped*/ )
|
|||
}
|
||||
|
||||
size_t ana_network_manager::send( network::connection connection_num ,
|
||||
const config& cfg,
|
||||
bool zipped )
|
||||
const config& cfg )
|
||||
{
|
||||
if ( ! zipped )
|
||||
throw std::runtime_error("All send operations should be zipped");
|
||||
|
||||
const std::string output_string = compress_config(cfg);
|
||||
|
||||
|
||||
|
|
|
@ -421,10 +421,10 @@ class ana_network_manager : public ana::listener_handler,
|
|||
size_t number_of_connections() const;
|
||||
|
||||
/** Send data to all created components. */
|
||||
size_t send_all( const config& cfg, bool zipped );
|
||||
size_t send_all( const config& cfg );
|
||||
|
||||
/** Send data to the component with a given ID. */
|
||||
size_t send( network::connection connection_num , const config& cfg, bool zipped );
|
||||
size_t send( network::connection connection_num , const config& cfg );
|
||||
|
||||
size_t send_raw_data( const char*, size_t, network::connection);
|
||||
|
||||
|
|
|
@ -118,7 +118,6 @@ struct buffer {
|
|||
config_buf(),
|
||||
config_error(""),
|
||||
stream(),
|
||||
gzipped(false),
|
||||
raw_buffer()
|
||||
{}
|
||||
|
||||
|
@ -127,12 +126,6 @@ struct buffer {
|
|||
std::string config_error;
|
||||
std::ostringstream stream;
|
||||
|
||||
/**
|
||||
* Do we wish to send the data gzipped, if not use binary wml. This needs
|
||||
* to stay until the last user of binary_wml has been removed.
|
||||
*/
|
||||
bool gzipped;
|
||||
|
||||
/**
|
||||
* This field is used if we're sending a raw buffer instead of through a
|
||||
* config object. It will contain the entire contents of the buffer being
|
||||
|
@ -356,19 +349,13 @@ bool receive_with_timeout(TCPsocket s, char* buf, size_t nbytes,
|
|||
return true;
|
||||
}
|
||||
|
||||
static void output_to_buffer(TCPsocket sock, const config& cfg, std::ostringstream& compressor, bool gzipped)
|
||||
/**
|
||||
* @todo See if the TCPsocket argument should be removed.
|
||||
*/
|
||||
static void output_to_buffer(TCPsocket /*sock*/, const config& cfg, std::ostringstream& compressor)
|
||||
{
|
||||
if(gzipped) {
|
||||
config_writer writer(compressor, true);
|
||||
writer.write(cfg);
|
||||
} else {
|
||||
compression_schema *compress;
|
||||
{
|
||||
const threading::lock lock(*schemas_mutex);
|
||||
compress = &schemas.insert(std::pair<TCPsocket,schema_pair>(sock,schema_pair())).first->second.outgoing;
|
||||
}
|
||||
write_compressed(compressor, cfg, *compress);
|
||||
}
|
||||
config_writer writer(compressor, true);
|
||||
writer.write(cfg);
|
||||
}
|
||||
|
||||
static void make_network_buffer(const char* input, int len, std::vector<char>& buf)
|
||||
|
@ -784,15 +771,16 @@ static int process_queue(void* shard_num)
|
|||
try {
|
||||
if(stream.peek() == 31) {
|
||||
read_gz(received_data->config_buf, stream);
|
||||
received_data->gzipped = true;
|
||||
} else {
|
||||
/// @todo This should probably be deprecated some day,
|
||||
/// if this network layer isn't replaced by ANA
|
||||
ERR_NW << "Receiving binary WML. Who is sending this?\n";
|
||||
compression_schema *compress;
|
||||
{
|
||||
const threading::lock lock_schemas(*schemas_mutex);
|
||||
compress = &schemas.insert(std::pair<TCPsocket,schema_pair>(sock,schema_pair())).first->second.incoming;
|
||||
}
|
||||
read_compressed(received_data->config_buf, stream, *compress);
|
||||
received_data->gzipped = false;
|
||||
}
|
||||
} catch(config::error &e)
|
||||
{
|
||||
|
@ -930,7 +918,7 @@ void receive_data(TCPsocket sock)
|
|||
}
|
||||
}
|
||||
|
||||
TCPsocket get_received_data(TCPsocket sock, config& cfg, bool* gzipped,network::bandwidth_in_ptr& bandwidth_in)
|
||||
TCPsocket get_received_data(TCPsocket sock, config& cfg, network::bandwidth_in_ptr& bandwidth_in)
|
||||
{
|
||||
assert(!raw_data_only);
|
||||
const threading::lock lock_received(*received_mutex);
|
||||
|
@ -950,16 +938,12 @@ TCPsocket get_received_data(TCPsocket sock, config& cfg, bool* gzipped,network::
|
|||
std::string error = (*itor)->config_error;
|
||||
buffer* buf = *itor;
|
||||
received_data_queue.erase(itor);
|
||||
if (gzipped)
|
||||
*gzipped = buf->gzipped;
|
||||
delete buf;
|
||||
throw config::error(error);
|
||||
} else {
|
||||
cfg.swap((*itor)->config_buf);
|
||||
const TCPsocket res = (*itor)->sock;
|
||||
buffer* buf = *itor;
|
||||
if (gzipped)
|
||||
*gzipped = buf->gzipped;
|
||||
bandwidth_in.reset(new network::bandwidth_in((*itor)->raw_buffer.size()));
|
||||
received_data_queue.erase(itor);
|
||||
delete buf;
|
||||
|
@ -1011,13 +995,12 @@ void queue_file(TCPsocket sock, const std::string& filename)
|
|||
queue_buffer(sock, queued_buf);
|
||||
}
|
||||
|
||||
size_t queue_data(TCPsocket sock,const config& buf, const bool gzipped, const std::string& packet_type)
|
||||
size_t queue_data(TCPsocket sock,const config& buf, const std::string& packet_type)
|
||||
{
|
||||
DBG_NW << "queuing data...\n";
|
||||
|
||||
buffer* queued_buf = new buffer(sock);
|
||||
output_to_buffer(sock, buf, queued_buf->stream, gzipped);
|
||||
queued_buf->gzipped = gzipped;
|
||||
output_to_buffer(sock, buf, queued_buf->stream);
|
||||
const size_t size = queued_buf->stream.str().size();
|
||||
|
||||
network::add_bandwidth_out(packet_type, size);
|
||||
|
|
|
@ -60,14 +60,14 @@ void set_use_system_sendfile(bool);
|
|||
/** Function to asynchronously received data to the given socket. */
|
||||
void receive_data(TCPsocket sock);
|
||||
|
||||
TCPsocket get_received_data(TCPsocket sock, config& cfg, bool* gzipped, network::bandwidth_in_ptr&);
|
||||
TCPsocket get_received_data(TCPsocket sock, config& cfg, network::bandwidth_in_ptr&);
|
||||
|
||||
TCPsocket get_received_data(std::vector<char>& buf);
|
||||
|
||||
void queue_file(TCPsocket sock, const std::string&);
|
||||
|
||||
void queue_raw_data(TCPsocket sock, const char* buf, int len);
|
||||
size_t queue_data(TCPsocket sock, const config& buf, const bool gzipped, const std::string& packet_type);
|
||||
size_t queue_data(TCPsocket sock, const config& buf, const std::string& packet_type);
|
||||
bool is_locked(const TCPsocket sock);
|
||||
bool close_socket(TCPsocket sock);
|
||||
TCPsocket detect_error();
|
||||
|
|
|
@ -129,7 +129,7 @@ void verify_and_get_global_variable(const vconfig &pcfg)
|
|||
config data;
|
||||
data.add_child("wait_global");
|
||||
data.child("wait_global")["side"] = side;
|
||||
network::send_data(data,0,true);
|
||||
network::send_data(data,0);
|
||||
}
|
||||
while (get_replay_source().at_end()) {
|
||||
ai::manager::raise_user_interact();
|
||||
|
|
|
@ -443,7 +443,7 @@ LEVEL_RESULT play_game(display& disp, game_state& gamestate, const config& game_
|
|||
}
|
||||
|
||||
// Ask for the next scenario data.
|
||||
network::send_data(config("load_next_scenario"), 0, true);
|
||||
network::send_data(config("load_next_scenario"), 0);
|
||||
config cfg;
|
||||
std::string msg = _("Downloading next scenario...");
|
||||
do {
|
||||
|
@ -552,7 +552,7 @@ LEVEL_RESULT play_game(display& disp, game_state& gamestate, const config& game_
|
|||
foreach (config& side, gamestate.starting_pos.child_range("side"))
|
||||
next_cfg.add_child("side", side);
|
||||
|
||||
network::send_data(cfg, 0, true);
|
||||
network::send_data(cfg, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -519,7 +519,7 @@ void playmp_controller::process_oos(const std::string& err_msg) const {
|
|||
config& info = cfg.add_child("info");
|
||||
info["type"] = "termination";
|
||||
info["condition"] = "out of sync";
|
||||
network::send_data(cfg, 0, true);
|
||||
network::send_data(cfg, 0);
|
||||
|
||||
std::stringstream temp_buf;
|
||||
std::vector<std::string> err_lines = utils::split(err_msg,'\n');
|
||||
|
|
|
@ -425,7 +425,7 @@ LEVEL_RESULT playsingle_controller::play_scenario(
|
|||
info["type"] = "termination";
|
||||
info["condition"] = "game over";
|
||||
info["result"] = gamestate_.classification().completion;
|
||||
network::send_data(cfg, 0, true);
|
||||
network::send_data(cfg, 0);
|
||||
} else {
|
||||
gui2::show_transient_message(gui_->video(),_("Game Over"),
|
||||
_("The game is over."));
|
||||
|
|
|
@ -115,7 +115,7 @@ turn_info::PROCESS_DATA_RESULT turn_info::process_network_data(const config& cfg
|
|||
config::const_child_itors turns = cfg.child_range("turn");
|
||||
if (turns.first != turns.second && from != network::null_connection) {
|
||||
//forward the data to other peers
|
||||
network::send_data_all_except(cfg, from, true);
|
||||
network::send_data_all_except(cfg, from);
|
||||
}
|
||||
|
||||
foreach (const config &t, turns)
|
||||
|
@ -323,7 +323,7 @@ void turn_info::change_controller(const std::string& side, const std::string& co
|
|||
change["side"] = side;
|
||||
change["controller"] = controller;
|
||||
|
||||
network::send_data(cfg, 0, true);
|
||||
network::send_data(cfg, 0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -334,7 +334,7 @@ void turn_info::change_side_controller(const std::string& side, const std::strin
|
|||
change["side"] = side;
|
||||
change["player"] = player;
|
||||
if (own_side) change["own_side"] = true;
|
||||
network::send_data(cfg, 0, true);
|
||||
network::send_data(cfg, 0);
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
|
|
@ -1184,7 +1184,7 @@ void replay_network_sender::sync_non_undoable()
|
|||
config cfg;
|
||||
const config& data = cfg.add_child("turn",obj_.get_data_range(upto_,obj_.ncommands(),replay::NON_UNDO_DATA));
|
||||
if(data.empty() == false) {
|
||||
network::send_data(cfg, 0, true);
|
||||
network::send_data(cfg, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1195,7 +1195,7 @@ void replay_network_sender::commit_and_sync()
|
|||
config cfg;
|
||||
const config& data = cfg.add_child("turn",obj_.get_data_range(upto_,obj_.ncommands()));
|
||||
if(data.empty() == false) {
|
||||
network::send_data(cfg, 0, true);
|
||||
network::send_data(cfg, 0);
|
||||
}
|
||||
|
||||
upto_ = obj_.ncommands();
|
||||
|
|
|
@ -911,7 +911,7 @@ void server::process_login(const network::connection sock,
|
|||
<< ":" << config_it->second["port"] << "\n";
|
||||
config response;
|
||||
response.add_child("redirect",config_it->second);
|
||||
network::send_data(response, sock, true, "redirect");
|
||||
network::send_data(response, sock, "redirect");
|
||||
return;
|
||||
}
|
||||
// Check if it's a version we should start a proxy for.
|
||||
|
@ -943,7 +943,7 @@ void server::process_login(const network::connection sock,
|
|||
ERR_SERVER << "ERROR: This server doesn't accept any versions at all.\n";
|
||||
response["version"] = "null";
|
||||
}
|
||||
network::send_data(response, sock, true, "error");
|
||||
network::send_data(response, sock, "error");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ BOOST_AUTO_TEST_CASE( test_send_client )
|
|||
|
||||
child["test"] = "yes!";
|
||||
cfg_send["test_running"] = true;
|
||||
network::send_data(cfg_send, client_client1, true);
|
||||
network::send_data(cfg_send, client_client1);
|
||||
|
||||
network::connection receive_from;
|
||||
config received;
|
||||
|
|
Loading…
Add table
Reference in a new issue