ENH: remove check link state
Change-Id: Iba16694299f92a89e63ea9c4829e3087a29bade1 Signed-off-by: Stone Li <stone.li@bambulab.com>
This commit is contained in:
parent
ddb20e0b13
commit
ebf9c19e65
|
@ -2774,9 +2774,6 @@ bool GUI_App::on_init_inner()
|
|||
}
|
||||
});
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << "start_check_network_state...";
|
||||
start_check_network_state();
|
||||
|
||||
m_initialized = true;
|
||||
|
||||
flush_logs();
|
||||
|
@ -4142,81 +4139,6 @@ void GUI_App::on_user_login_handle(wxCommandEvent &evt)
|
|||
}
|
||||
}
|
||||
|
||||
void GUI_App::start_check_network_state()
|
||||
{
|
||||
boost::thread* test_microsoft = new boost::thread([this] {
|
||||
start_test_url("www.microsoft.com");
|
||||
});
|
||||
boost::thread* test_apple = new boost::thread([this] {
|
||||
start_test_url("www.apple.com");
|
||||
});
|
||||
boost::thread* test_amazon = new boost::thread([this] {
|
||||
start_test_url("www.amazon.com");
|
||||
});
|
||||
|
||||
m_check_network_thread = boost::thread([this] {
|
||||
int sec_count = 1;
|
||||
while (!m_is_closing) {
|
||||
if (sec_count % 10 == 0) {
|
||||
bool link_result = check_network_state();
|
||||
if (!link_result) {
|
||||
BOOST_LOG_TRIVIAL(info) << "link_result = " << link_result;
|
||||
}
|
||||
}
|
||||
boost::this_thread::sleep_for(boost::chrono::milliseconds(1000));
|
||||
sec_count++;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
bool GUI_App::check_network_state()
|
||||
{
|
||||
bool result = false;
|
||||
for (auto link : test_url_state) {
|
||||
result = result | link.second;
|
||||
}
|
||||
if (m_agent) {
|
||||
if (result)
|
||||
m_agent->track_update_property("link_state", "1");
|
||||
else
|
||||
m_agent->track_update_property("link_state", "0");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void GUI_App::start_test_url(std::string url)
|
||||
{
|
||||
int sec_count = 0;
|
||||
while (!m_is_closing) {
|
||||
if (sec_count % 10 == 0) {
|
||||
Slic3r::Http http = Slic3r::Http::get(url);
|
||||
int result = -1;
|
||||
http.timeout_max(5)
|
||||
.on_complete([&result](std::string body, unsigned status) {
|
||||
try {
|
||||
if (status == 200) {
|
||||
result = 0;
|
||||
}
|
||||
}
|
||||
catch (...) {
|
||||
;
|
||||
}
|
||||
})
|
||||
.on_error([](std::string body, std::string error, unsigned int status) {
|
||||
;
|
||||
}).perform_sync();
|
||||
|
||||
if (result == 0) {
|
||||
test_url_state[url] = true;
|
||||
} else {
|
||||
test_url_state[url] = false;
|
||||
}
|
||||
}
|
||||
boost::this_thread::sleep_for(boost::chrono::milliseconds(1000));
|
||||
sec_count++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GUI_App::check_track_enable()
|
||||
{
|
||||
|
|
|
@ -430,9 +430,6 @@ public:
|
|||
void on_set_selected_machine(wxCommandEvent& evt);
|
||||
void on_user_login(wxCommandEvent &evt);
|
||||
void on_user_login_handle(wxCommandEvent& evt);
|
||||
void start_check_network_state();
|
||||
bool check_network_state();
|
||||
void start_test_url(std::string url);
|
||||
void enable_user_preset_folder(bool enable);
|
||||
|
||||
// BBS
|
||||
|
|
Loading…
Reference in New Issue