Skip to content

Commit 2fca8db

Browse files
committed
fix: Set DeviceListV4 message to id 0 on device added/removed
DeviceListV4 is a message that can now either be system OR response, like Error. We need to make sure the id is set to 0 in added/removed situations, otherwise message matching can get confused since we'll default the ID to 1 on serialization. Fixes #848
1 parent dd2e5f1 commit 2fca8db

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

crates/buttplug_server/src/device/server_device_manager_event_loop.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// for full license information.
77

88
use buttplug_core::{
9-
message::{ButtplugServerMessageV4, DeviceListV4, ScanningFinishedV0},
9+
message::{ButtplugMessage, ButtplugServerMessageV4, DeviceListV4, ScanningFinishedV0},
1010
};
1111
use buttplug_server_device_config::DeviceConfigurationManager;
1212
use tracing::info_span;
@@ -325,7 +325,11 @@ impl ServerDeviceManagerEventLoop {
325325
.iter()
326326
.map(|device| device.value().as_device_message_info(*device.key()))
327327
.collect();
328-
DeviceListV4::new(devices)
328+
let mut device_list = DeviceListV4::new(devices);
329+
// If we're creating a device list in the event loop, this means a device was either added or
330+
// removed. Therefore this is a system message, not a reply message.
331+
device_list.set_id(0);
332+
device_list
329333
}
330334

331335
async fn handle_device_event(&mut self, device_event: InternalDeviceEvent) {

0 commit comments

Comments
 (0)