From ef3e5621e4ea479df172976394c2f636f45bf6fb Mon Sep 17 00:00:00 2001 From: slonkazoid Date: Thu, 10 Jul 2025 17:57:16 +0300 Subject: [PATCH 1/5] add DeviceListReceived event --- buttplug/src/client/mod.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/buttplug/src/client/mod.rs b/buttplug/src/client/mod.rs index 5af9ebaa2..681a671ca 100644 --- a/buttplug/src/client/mod.rs +++ b/buttplug/src/client/mod.rs @@ -128,6 +128,9 @@ pub enum ButtplugClientEvent { /// Emitted when a device has been removed from the server. Includes a /// [ButtplugClientDevice] object representing the device. DeviceRemoved(Arc), + /// Emitted when the device list is received as a response to a + /// DeviceListRequest call, which is sent during the handshake. + DeviceListReceived, /// Emitted when a client has not pinged the server in a sufficient amount of /// time. PingTimeout, @@ -354,7 +357,7 @@ impl ButtplugClient { .message_sender .send_message(RequestDeviceListV0::default().into()) .await?; - if let ButtplugServerMessageV3::DeviceList(m) = msg { + if let ButtplugServerMessageV3::DeviceList(m) = dbg!(msg) { self .message_sender .send_message_to_event_loop(ButtplugClientRequest::HandleDeviceList(m)) From 1a19c6e09f848c50c64fd6bdec85a2e556ea6e55 Mon Sep 17 00:00:00 2001 From: slonkazoid Date: Thu, 10 Jul 2025 17:57:30 +0300 Subject: [PATCH 2/5] emit the DeviceListReceived event --- buttplug/src/client/client_event_loop.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/buttplug/src/client/client_event_loop.rs b/buttplug/src/client/client_event_loop.rs index 6b6bc6d5a..caf8e53b2 100644 --- a/buttplug/src/client/client_event_loop.rs +++ b/buttplug/src/client/client_event_loop.rs @@ -314,6 +314,7 @@ where let device = self.create_client_device(d); self.send_client_event(ButtplugClientEvent::DeviceAdded(device)); } + self.send_client_event(ButtplugClientEvent::DeviceListReceived); true } } From ce17e9fd6ee62e2f89e514ed4dec8a035250898c Mon Sep 17 00:00:00 2001 From: slonkazoid Date: Thu, 10 Jul 2025 18:09:04 +0300 Subject: [PATCH 3/5] fixup! add DeviceListReceived event --- buttplug/src/client/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buttplug/src/client/mod.rs b/buttplug/src/client/mod.rs index 681a671ca..f0bebf966 100644 --- a/buttplug/src/client/mod.rs +++ b/buttplug/src/client/mod.rs @@ -357,7 +357,7 @@ impl ButtplugClient { .message_sender .send_message(RequestDeviceListV0::default().into()) .await?; - if let ButtplugServerMessageV3::DeviceList(m) = dbg!(msg) { + if let ButtplugServerMessageV3::DeviceList(m) = msg { self .message_sender .send_message_to_event_loop(ButtplugClientRequest::HandleDeviceList(m)) From 4cf637dd24eefcc2b18dbfbdbe2409067cb4cdd1 Mon Sep 17 00:00:00 2001 From: slonkazoid Date: Thu, 10 Jul 2025 18:41:32 +0300 Subject: [PATCH 4/5] adjust test to accomodate for new event --- buttplug/tests/test_client.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/buttplug/tests/test_client.rs b/buttplug/tests/test_client.rs index 92951efc6..05fcededc 100644 --- a/buttplug/tests/test_client.rs +++ b/buttplug/tests/test_client.rs @@ -142,6 +142,10 @@ async fn test_client_scanning_finished() { let (client, _) = test_client_with_device().await; let mut recv = client.event_stream(); assert!(client.start_scanning().await.is_ok()); + assert!(matches!( + recv.next().await.expect("Test, assuming infallible."), + ButtplugClientEvent::DeviceListReceived + )); assert!(matches!( recv.next().await.expect("Test, assuming infallible."), ButtplugClientEvent::ScanningFinished From 29074a067bc67fd014ca7e83f875693e8e56d561 Mon Sep 17 00:00:00 2001 From: slonkazoid Date: Mon, 17 Nov 2025 16:23:51 +0300 Subject: [PATCH 5/5] fixup! Merge remote-tracking branch 'upstream/master' --- crates/buttplug_client/src/client_event_loop.rs | 1 + crates/buttplug_client/src/lib.rs | 3 +++ 2 files changed, 4 insertions(+) diff --git a/crates/buttplug_client/src/client_event_loop.rs b/crates/buttplug_client/src/client_event_loop.rs index eae8b5177..4cab7d781 100644 --- a/crates/buttplug_client/src/client_event_loop.rs +++ b/crates/buttplug_client/src/client_event_loop.rs @@ -301,6 +301,7 @@ where let device = self.create_client_device(device); self.send_client_event(ButtplugClientEvent::DeviceAdded(device)); } + self.send_client_event(ButtplugClientEvent::DeviceListReceived); true } } diff --git a/crates/buttplug_client/src/lib.rs b/crates/buttplug_client/src/lib.rs index ee6572b36..3710bcce6 100644 --- a/crates/buttplug_client/src/lib.rs +++ b/crates/buttplug_client/src/lib.rs @@ -123,6 +123,9 @@ pub enum ButtplugClientEvent { /// Emitted when a scanning session (started via a StartScanning call on /// [ButtplugClient]) has finished. ScanningFinished, + /// Emitted when the device list is received as a response to a + /// DeviceListRequest call, which is sent during the handshake. + DeviceListReceived, /// Emitted when a device has been added to the server. Includes a /// [ButtplugClientDevice] object representing the device. DeviceAdded(ButtplugClientDevice),