buttplugio / buttplug-rs-ffi

FFI from buttplug-rs to Java and other languages
Other
88 stars 22 forks source link

Reconnecting to a server with already connected devices can cause repeated DeviceAdded calls #56

Closed qdot closed 3 years ago

qdot commented 3 years ago

Describe the bug

  1. Using the C# library, connect to intiface desktop via websockets
  2. Scan for devices, preferably a lovense device?
  3. After device is found, disconnect, but leave server running
  4. Reconnect to server

Expected behavior We should get one DeviceAdded message

Actual behavior We get repeated DeviceAdded messages for the same device.

qdot commented 3 years ago

Problem is here:

https://github.com/buttplugio/buttplug-rs-ffi/blob/4ba2cc935aa0caafb611e86b6b497ba029e2a23a/ffi/src/client.rs#L95-L99

We spawn a new event stream listener every time we connect in a client, meaning multiple reconnections create multiple tasks, firing multiple events.

Fix is to just spin up the forwarder task on client construction.