Documentation ¶
Overview ¶
Package golibbuttplug provides a Buttplug websocket client.
Buttplug (https://buttplug.io/) is a quasi-standard set of technologies and protocols to allow developers to write software that controls an array of sex toys in a semi-future-proof way.
Index ¶
- Constants
- Variables
- type Client
- type Device
- func (d *Device) Disconnected() <-chan struct{}
- func (d *Device) FleshlightLaunchFW12Cmd(pos, spd int) error
- func (d *Device) IsSupported(msgtype string) bool
- func (d *Device) KiirooCmd(cmd int) error
- func (d *Device) LovenseCmd(cmd string) error
- func (d *Device) Name() string
- func (d *Device) RawCmd(cmd []byte) error
- func (d *Device) SingleMotorVibrateCmd(spd float64) error
- func (d *Device) StopDeviceCmd() error
- func (d *Device) String() string
- func (d *Device) Supported() []string
- func (d *Device) VorzeA10CycloneCmd(spd int, clockwise bool) error
Examples ¶
Constants ¶
const ( // CommandStopDevice ... CommandStopDevice = "StopDeviceCmd" // CommandRaw ... CommandRaw = "RawCmd" // CommandSingleMotorVibrate ... CommandSingleMotorVibrate = "SingleMotorVibrateCmd" // CommandKiiroo ... CommandKiiroo = "KiirooCmd" // CommandFleshlightLaunchFW12 ... CommandFleshlightLaunchFW12 = "FleshlightLaunchFW12Cmd" // CommandLovense ... CommandLovense = "LovenseCmd" // CommandVorzeA10Cyclone ... CommandVorzeA10Cyclone = "VorzeA10CycloneCmd" )
const DefaultName = "golibbuttplug"
DefaultName is used when no name is specified when creating a new client.
Variables ¶
var ( // ErrUnsupported is the error returned when the command executed is // not supported by the device. ErrUnsupported = errors.New("unsupported command") // ErrInvalidSpeed is the error retured when the speed is not supported // by the device. ErrInvalidSpeed = errors.New("invalid speed") // ErrInvalidPosition is the error retured when the position is not // supported by the device. ErrInvalidPosition = errors.New("invalid position") // ErrInvalidCmd is the error retured when the command is not // supported by the device. ErrInvalidCmd = errors.New("invalid command") )
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a websocket API client that performs operations against a Buttplug server.
Example ¶
This example demonstrates how to connect to Buttplug server websocket, search for devices and perform operations on the discovered devices.
// Contexts can be used to cancel client connection. rootctx := context.Background() // Create a new session with the server as "ExampleClient". c, err := NewClient(rootctx, "ws://127.0.0.1:12345", "ExampleClient", nil) if err != nil { log.Fatal(err) } // Scan for devices. if err := c.StartScanning(); err != nil { log.Fatal(err) } // Wait for scanning to finish. ctx, cancel := context.WithTimeout(rootctx, 30*time.Second) err = c.WaitOnScanning(ctx) cancel() if err == context.DeadlineExceeded { // Stop scanning. if err := c.StopScanning(); err != nil { log.Fatal(err) } } else if err != nil { log.Fatal(err) } // Get all known devices. for _, d := range c.Devices() { // Test if the RawCmd is supported by the device. if d.IsSupported("RawCmd") { log.Printf("%s supports RawCmd", d.Name()) // Send a RawCmd. if err := d.RawCmd([]byte{0x00, 0x10}); err != nil { log.Printf("RawCmd failed: %v", err) } } // Try sending a Fleshlight Launch command. if err := d.FleshlightLaunchFW12Cmd(50, 20); err != nil { log.Printf("Launch command failed: %v", err) } } // Stop all devices. if err := c.StopAllDevices(); err != nil { log.Fatal(err) } // Close the connection. c.Close()
Output:
func (*Client) Disconnected ¶
func (c *Client) Disconnected() <-chan struct{}
Disconnected returns a receiver channel that is closed when the client has stopped.
func (*Client) StartScanning ¶
StartScanning requests to have the server start scanning for devices on all busses that it knows about. Useful for protocols like Bluetooth, which require an explicit discovery phase.
func (*Client) StopAllDevices ¶
StopAllDevices tells the server to stop all devices. Can be used for emergency situations, on client shutdown for cleanup, etc.
func (*Client) StopScanning ¶
StopScanning requests to have the server stop scanning for devices. Useful for protocols like Bluetooth, which may not timeout otherwise.
type Device ¶
type Device struct {
// contains filtered or unexported fields
}
Device structs represents a connected device and can be used to execute commands.
func (*Device) Disconnected ¶
func (d *Device) Disconnected() <-chan struct{}
Disconnected returns a receiving channel, that is closed when the device is removed.
func (*Device) FleshlightLaunchFW12Cmd ¶
FleshlightLaunchFW12Cmd causes a toy that supports Fleshlight Launch (Firmware Version 1.2) style commands to run whatever event may be related.
func (*Device) IsSupported ¶
IsSupported returns true if the message type is supported.
func (*Device) KiirooCmd ¶
KiirooCmd causes a toy that supports Kiiroo style commands to run whatever event may be related.
func (*Device) LovenseCmd ¶
LovenseCmd causes a toy that supports Lovense style commands to run whatever event may be related.
func (*Device) SingleMotorVibrateCmd ¶
SingleMotorVibrateCmd causes a toy that supports vibration to run at a certain speed. In order to abstract the dynamic range of different toys, the value sent is a float with a range of [0.0-1.0].
func (*Device) StopDeviceCmd ¶
StopDeviceCmd stops a device from whatever actions it may be taking.
Directories ¶
Path | Synopsis |
---|---|
Package buttplugtest provides utilities for buttplug testing.
|
Package buttplugtest provides utilities for buttplug testing. |
Package message contains types and handlers for Buttplug messages.
|
Package message contains types and handlers for Buttplug messages. |