buttplugtest

package
v0.0.0-...-0cf68e8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2017 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package buttplugtest provides utilities for buttplug testing.

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultAddDeviceMessage can be used to simulate adding a Launch.
	DefaultAddDeviceMessage = &message.Device{
		ID:             0,
		DeviceName:     "Launch",
		DeviceIndex:    3,
		DeviceMessages: []string{"FleshlightLaunchFW12Cmd", "KiirooCmd", "RawCmd", "StopDeviceCmd"},
	}
	// DefaultRemoveDeviceMessage can be used to remove the added Launch.
	DefaultRemoveDeviceMessage = &message.Device{
		ID:          0,
		DeviceIndex: 3,
	}
)
View Source
var DefaultTestServer = &TestServer{
	InitialDevices: []message.Device{
		{
			DeviceName:     "TestDevice 1",
			DeviceIndex:    0,
			DeviceMessages: []string{"SingleMotorVibrateCmd", "RawCmd", "KiirooCmd", "StopDeviceCmd"},
		},
		{
			DeviceName:     "TestDevice 2",
			DeviceIndex:    1,
			DeviceMessages: []string{"SingleMotorVibrateCmd", "LovenseCmd", "StopDeviceCmd"},
		},
		{
			DeviceName:     "Launch",
			DeviceIndex:    2,
			DeviceMessages: []string{"FleshlightLaunchFW12Cmd", "KiirooCmd", "RawCmd", "StopDeviceCmd"},
		},
	},
}

DefaultTestServer is a TestServer with some predefined devices.

Functions

This section is empty.

Types

type Conn

type Conn struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Conn is an established websocket connection with the testserver.

func (*Conn) AddDevice

func (c *Conn) AddDevice(d *message.Device)

AddDevice will send the a message to the client that the given device has been added.

func (*Conn) ReadMessages

func (c *Conn) ReadMessages() error

ReadMessages will read the messages from the websocket to be read and handled.

func (*Conn) RemoveDevice

func (c *Conn) RemoveDevice(d *message.Device)

RemoveDevice will send the a message to the client that the given device has been removed.

func (*Conn) SendScanningFinished

func (c *Conn) SendScanningFinished()

SendScanningFinished will send a message to the client that scanning is finished.

type TestServer

type TestServer struct {
	InitialDevices []message.Device
	Conn           *Conn
}

TestServer is a mock of a Buttplug server.

func (*TestServer) ServeHTTP

func (t *TestServer) ServeHTTP(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL