mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-11-22 21:50:51 -05:00
Fix LAN Bambu printer losing its connection when the cloud server connects (#17769)
The server-connected handler selects the agent's current machine again every time the cloud server connects. For a LAN printer this makes the Bambu network plug-in unsubscribe the device, which drops the LAN session that selecting the printer opened. A connect still in flight fails with "called UnSubscribeDevice". One that already succeeded stays down with no connect result, so the printer shows as connected while every command fails with -4 and Print fails with -4030. Since #17086, OrcaSlicer connects the last LAN Bambu printer at startup, so a LAN user hits this on most starts. A cloud reconnect later in a session drops the session the same way. The selection is a cloud subscription, so a LAN printer does not need it. Move the re-select into DeviceManager::reselect_cloud_machine(), which skips a LAN-mode printer and behaves as before for any other machine. Fixes #17766
This commit is contained in:
1 parent
f2eb53ebaa
commit
a8a597c6d5
4 files changed
+62
-2
No files matched your search
@@ -865,6 +865,23 @@ namespace Slic3r
|
||||
m_agent->add_subscribe(subscribe_list_cache);
|
||||
}
|
||||
|
||||
void DeviceManager::reselect_cloud_machine()
|
||||
{
|
||||
if (!m_agent)
|
||||
return;
|
||||
|
||||
// The selection is a cloud subscription, and a LAN printer has none. Selecting one makes the
|
||||
// Bambu network plugin unsubscribe the device, which drops the LAN session that connected it:
|
||||
// a connect still in flight fails, and one that already succeeded stays down with no connect
|
||||
// result to say so.
|
||||
const std::string dev_id = m_agent->get_user_selected_machine();
|
||||
const MachineObject* obj = get_my_machine(dev_id);
|
||||
if (obj && obj->is_lan_mode_printer())
|
||||
return;
|
||||
|
||||
m_agent->set_user_selected_machine(dev_id);
|
||||
}
|
||||
|
||||
std::map<std::string, MachineObject*> DeviceManager::get_my_machine_list(const std::string& agent_id)
|
||||
{
|
||||
std::map<std::string, MachineObject*> result;
|
||||
|
||||
@@ -104,6 +104,9 @@ public:
|
||||
void add_user_subscribe();
|
||||
void del_user_subscribe();
|
||||
void subscribe_device_list(std::vector<std::string> dev_list);
|
||||
// Selects the agent's selected machine again, which subscribes a cloud printer once the cloud
|
||||
// server has connected. A LAN printer is left as it is.
|
||||
void reselect_cloud_machine();
|
||||
|
||||
/* my machine*/
|
||||
MachineObject* get_my_machine(std::string dev_id);
|
||||
|
||||
@@ -2341,12 +2341,14 @@ void GUI_App::init_networking_callbacks()
|
||||
if (provider != this->get_printer_cloud_provider()) {
|
||||
return;
|
||||
}
|
||||
m_agent->set_user_selected_machine(m_agent->get_user_selected_machine());
|
||||
if (m_device_manager)
|
||||
m_device_manager->reselect_cloud_machine();
|
||||
if (this->is_enable_multi_machine()) {
|
||||
auto evt = new wxCommandEvent(EVT_UPDATE_MACHINE_LIST);
|
||||
wxQueueEvent(this, evt);
|
||||
}
|
||||
m_agent->set_user_selected_machine(m_agent->get_user_selected_machine());
|
||||
if (m_device_manager)
|
||||
m_device_manager->reselect_cloud_machine();
|
||||
if (m_agent->is_user_login(provider)) {
|
||||
|
||||
/*disconnect lan*/
|
||||
|
||||
@@ -70,9 +70,16 @@ public:
|
||||
return 0;
|
||||
}
|
||||
|
||||
int set_user_selected_machine(std::string dev_id) override
|
||||
{
|
||||
++selections;
|
||||
return OrcaPrinterAgent::set_user_selected_machine(std::move(dev_id));
|
||||
}
|
||||
|
||||
std::string published_device;
|
||||
json published_message;
|
||||
std::string connected_ca_file;
|
||||
int selections{0};
|
||||
|
||||
private:
|
||||
AgentInfo m_info;
|
||||
@@ -277,6 +284,37 @@ TEST_CASE("Logging out cancels a pending last-machine restore", "[DeviceManager]
|
||||
CHECK_FALSE(manager.has_pending_last_machine_restore());
|
||||
}
|
||||
|
||||
TEST_CASE("A cloud server connection selects a cloud printer again but leaves a LAN printer alone", "[DeviceManager][integration]")
|
||||
{
|
||||
ScopedAppConfig app_config;
|
||||
auto agent = std::make_shared<TestPrinterAgent>("integration-agent");
|
||||
NetworkAgent network(nullptr, agent);
|
||||
network.set_printer_agent(agent);
|
||||
DeviceManager manager(&network, false, &app_config.config);
|
||||
|
||||
BBLocalMachine machine;
|
||||
machine.dev_id = "integration-lan-device";
|
||||
machine.dev_name = "Integration LAN device";
|
||||
machine.dev_ip = "192.0.2.10";
|
||||
machine.printer_type = "C11";
|
||||
REQUIRE(manager.insert_local_device(machine, "lan", "free", "", "access-code") != nullptr);
|
||||
manager.parse_user_print_info(machine_list_response(ORCA_CLOUD_PROVIDER, "integration-agent",
|
||||
network.get_user_machine_list_generation(), "Cloud printer"));
|
||||
REQUIRE(manager.get_user_machinelist().count("integration-device") == 1);
|
||||
|
||||
// The agent names the LAN printer once it is connected, as the Bambu network plugin does.
|
||||
agent->set_user_selected_machine(machine.dev_id);
|
||||
agent->selections = 0;
|
||||
manager.reselect_cloud_machine();
|
||||
CHECK(agent->selections == 0);
|
||||
|
||||
agent->set_user_selected_machine("integration-device");
|
||||
agent->selections = 0;
|
||||
manager.reselect_cloud_machine();
|
||||
CHECK(agent->selections == 1);
|
||||
CHECK(agent->get_user_selected_machine() == "integration-device");
|
||||
}
|
||||
|
||||
TEST_CASE("A CA file stays with the agent that saved it when a device is rebound", "[DeviceManager][integration]")
|
||||
{
|
||||
ScopedAppConfig app_config;
|
||||
|
||||
Reference in new issue
Block a user