How to use the buttplug.FromJSON 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-node-websockets / src / ButtplugNodeWebsocketServer.ts View on Github external
client.on("message", async (message) => {
        const msg = FromJSON(message);
        for (const m of msg) {
          const outgoing = await bs.SendMessage(m);
          // Make sure our message is packed in an array, as the buttplug spec
          // requires.
          client.send("[" + outgoing.toJSON() + "]");
        }
      });
github buttplugio / buttplug-js / packages / buttplug-node-websockets / src / ButtplugNodeWebsocketClientConnector.ts View on Github external
private ParseIncomingMessage = (aMsg: WebSocket.Data) => {
    if (typeof (aMsg) === "string") {
      const msgs = FromJSON(aMsg);
      const emitMsgs = this._sorter.ParseIncomingMessages(msgs);
      this.emit("message", emitMsgs);
    } else {
      throw new ButtplugMessageException("Unknown message transfer type");
    }
  }