How to use the buttplug.ButtplugEmbeddedServerConnector function in buttplug

To help you get started, we’ve selected a few buttplug examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github buttplugio / buttplug-js / packages / buttplug-server-cli / src / local.ts View on Github external
async function main() {
  process.on("unhandledRejection", (reason, p) => {
    console.log("Unhandled Rejection at: Promise", p, "reason:", reason);
    // application specific logging, throwing an error, or other logic here
  });

  commander
    .version("0.0.1-alpha")
    .parse(process.argv);
  let res;
  const p = new Promise((resolve, reject) => { res = resolve });
  const bs = new ButtplugServer();
  bs.AddDeviceManager(new ButtplugNodeBluetoothLEDeviceManager());
  const localConnector = new ButtplugEmbeddedServerConnector();
  localConnector.Server = bs;
  const bc = new ButtplugClient("Buttplug Local Client");
  await bc.Connect(localConnector);
  bc.on("deviceadded", (d) => {
    console.log(`Device Found: ${d.Name}`);
    res();
  });
  console.log("starting scan");
  await bc.StartScanning();
  console.log("scanning");
  await p;
  console.log("Found a device, exiting.")
  await bc.Disconnect();
  process.exit();
}
github buttplugio / buttplug-js / packages / buttplug-node-bluetoothle-manager / example / device-scanning.js View on Github external
let main = async () => {

  const connector = new Buttplug.ButtplugEmbeddedServerConnector();
  const client = new Buttplug.ButtplugClient("Device Scanning Example");
  await client.Connect(connector);

  const dm = new ButtplugBLE.ButtplugNodeBluetoothLEDeviceManager();
  console.log("Initializing Bluetooth adapter...");
  await dm.Initialize();
  connector.Server.AddDeviceManager(dm);

  console.log("Scanning for devices...");
  client.on("deviceadded", (device) => {
    console.log(device.Name);
    device.SendVibrateCmd(1);
  });

  await client.StartScanning();
};