mirror of
https://github.com/BeamMP/BeamMP-Launcher.git
synced 2025-07-04 00:47:23 +00:00
add send debug message
This commit is contained in:
parent
c6e07cd26b
commit
120a51e2c7
@ -390,12 +390,13 @@ void ClientNetwork::client_tcp_write(bmp::ClientPacket& packet) {
|
||||
// copy packet data (yes i know ugh) to the `data` in order to send it in one go
|
||||
std::copy(packet.raw_data.begin(), packet.raw_data.end(), data.begin() + long(offset));
|
||||
boost::asio::async_write(m_game_socket, buffer(data),
|
||||
[this](auto ec, auto) {
|
||||
[this, packet](auto ec, auto) {
|
||||
if (ec) {
|
||||
spdlog::error("Failed to write a packet: {}", ec.message());
|
||||
disconnect("Failed to send data to game");
|
||||
} else {
|
||||
// ok! sent all data
|
||||
spdlog::debug("Sent packet: 0x{:x}", int(packet.purpose));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
20
src/Http.cpp
20
src/Http.cpp
@ -1,5 +1,3 @@
|
||||
#define CPPHTTPLIB_OPENSSL_SUPPORT
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <spdlog/spdlog.h>
|
||||
@ -18,7 +16,7 @@ std::string HTTP::Get(const std::string &IP) {
|
||||
httplib::Client cli(IP.substr(0, pos).c_str());
|
||||
cli.set_connection_timeout(std::chrono::seconds(10));
|
||||
cli.set_follow_location(true);
|
||||
auto res = cli.Get(IP.substr(pos).c_str(), ProgressBar);
|
||||
auto res = cli.Get(IP.substr(pos).c_str());
|
||||
std::string Ret;
|
||||
|
||||
if(res){
|
||||
@ -73,22 +71,6 @@ std::string HTTP::Post(const std::string& IP, const std::string& Fields) {
|
||||
else return Ret;
|
||||
}
|
||||
|
||||
bool HTTP::ProgressBar(size_t c, size_t t){
|
||||
if(isDownload) {
|
||||
static double last_progress, progress_bar_adv;
|
||||
progress_bar_adv = round(c / double(t) * 25);
|
||||
std::cout << "\r";
|
||||
std::cout << "Progress : [ ";
|
||||
std::cout << round(c / double(t) * 100);
|
||||
std::cout << "% ] [";
|
||||
int i;
|
||||
for (i = 0; i <= progress_bar_adv; i++)std::cout << "#";
|
||||
for (i = 0; i < 25 - progress_bar_adv; i++)std::cout << ".";
|
||||
std::cout << "]";
|
||||
last_progress = round(c / double(t) * 100);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool HTTP::Download(const std::string &IP, const std::string &Path) {
|
||||
static std::mutex Lock;
|
||||
|
@ -89,8 +89,6 @@ int main(int argc, char** argv) {
|
||||
launcher.start_game();
|
||||
}
|
||||
|
||||
launcher.client_network->handle_server_packet(bmp::Packet {});
|
||||
|
||||
while (true) {
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user