fixes an issue that devmgr ping cloud server every second

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
SoftFever
2026-05-03 16:59:30 +08:00
parent 522343a193
commit 84d896bbd3
4 changed files with 15 additions and 6 deletions

View File

@@ -913,12 +913,13 @@ namespace Slic3r
}
// do some refresh
if (Slic3r::GUI::wxGetApp().is_user_login(Slic3r::GUI::wxGetApp().get_printer_cloud_provider()))
const auto cloud_provider = Slic3r::GUI::wxGetApp().get_printer_cloud_provider();
if (Slic3r::GUI::wxGetApp().is_user_login(cloud_provider))
{
m_manager->check_pushing();
try
{
agent->refresh_connection();
agent->refresh_connection(cloud_provider);
}
catch (...)
{

View File

@@ -116,7 +116,7 @@ public:
class DeviceManagerRefresher : public wxObject
{
wxTimer* m_timer{ nullptr };
int m_timer_interval_msec = 1000;
int m_timer_interval_msec = 5000;
DeviceManager* m_manager{ nullptr };

View File

@@ -340,9 +340,17 @@ bool NetworkAgent::is_server_connected(const std::string& provider)
return false;
}
int NetworkAgent::refresh_connection()
int NetworkAgent::refresh_connection(const std::string& provider)
{
if(provider.empty())
return invoke_on_all_cloud_agents(m_cloud_agents, [](ICloudServiceAgent& cloud_agent) { return cloud_agent.refresh_connection(); });
else {
const auto cloud_agent = get_cloud_agent(provider);
if (cloud_agent)
return cloud_agent->refresh_connection();
return -1;
}
}
void NetworkAgent::enable_multi_machine(bool enable, const std::string& provider)

View File

@@ -71,7 +71,7 @@ public:
int set_on_http_error_fn(AppOnHttpErrorFn fn);
int set_get_country_code_fn(GetCountryCodeFn fn);
int connect_server();
int refresh_connection();
int refresh_connection(const std::string& provider = "");
int change_user(std::string user_info, const std::string& provider = ORCA_CLOUD_PROVIDER);
bool is_user_login(const std::string& provider = ORCA_CLOUD_PROVIDER);