MCPcopy Create free account
hub / github.com/buttplugio/buttplug / disconnect

Method disconnect

crates/buttplug_client/src/lib.rs:390–409  ·  view source on GitHub ↗

Disconnects from server, if connected. Returns Err(ButtplugClientError) if disconnection fails. It can be assumed that even on failure, the client will be disconnected.

(&self)

Source from the content-addressed store, hash-verified

388 /// Returns Err(ButtplugClientError) if disconnection fails. It can be assumed
389 /// that even on failure, the client will be disconnected.
390 pub fn disconnect(&self) -> ButtplugClientResultFuture {
391 if !self.connected() {
392 return future::ready(Err(ButtplugConnectorError::ConnectorNotConnected.into())).boxed();
393 }
394 // Send the connector to the internal loop for management. Once we throw
395 // the connector over, the internal loop will handle connecting and any
396 // further communications with the server, if connection is successful.
397 let (tx, rx) = oneshot::channel();
398 let msg = ButtplugClientRequest::Disconnect(tx);
399 let send_fut = self.message_sender.send_message_to_event_loop(msg);
400 let connected = self.connected.clone();
401 async move {
402 connected.store(false, Ordering::Relaxed);
403 send_fut.await?;
404 // Wait for disconnect to complete, but don't fail if channel closed
405 let _ = rx.await;
406 Ok(())
407 }
408 .boxed()
409 }
410
411 /// Tells server to start scanning for devices.
412 ///

Callers 7

main.tsFile · 0.45
mainFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45
run_handshakeMethod · 0.45
parse_client_requestMethod · 0.45

Calls 4

OkClass · 0.85
cloneMethod · 0.80
connectedMethod · 0.45

Tested by

no test coverage detected