message

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: 4 Imported by: 0

Documentation

Overview

Package message contains types and handlers for Buttplug messages.

Index

Constants

View Source
const (
	// LogLevelOff ...
	LogLevelOff = "Off"
	// LogLevelFatal ...
	LogLevelFatal = "Fatal"
	// LogLevelError ...
	LogLevelError = "Error"
	// LogLevelWarn ...
	LogLevelWarn = "Warn"
	// LogLevelInfo ...
	LogLevelInfo = "Info"
	// LogLevelDebug ...
	LogLevelDebug = "Debug"
	// LogLevelTrace ...
	LogLevelTrace = "Trace"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Device

type Device struct {
	// Message ID (not used when received in a device list.)
	ID uint32 `json:"Id,omitempty"`
	// Descriptive name of the device.
	DeviceName string
	// Index used to identify the device when sending Device Messages.
	DeviceIndex uint32
	// Type names of Device Messages that the device will accept.
	DeviceMessages []string `json:"DeviceMessages,omitempty"`
}

Device ...

type DeviceList

type DeviceList struct {
	// The ID of the client message that this reply is in response to.
	ID uint32 `json:"Id"`
	// Array of device objects
	Devices []Device
}

DeviceList is a server reply to a client request for a device list.

type Empty

type Empty struct {
	// The ID the message.
	ID uint32 `json:"Id"`
}

Empty message is used for all request and responses without additional properties.

type Error

type Error struct {
	// The ID of the client message that this reply is in response to.
	ID uint32 `json:"Id"`
	// Message describing the error that happened on the server.
	ErrorMessage string
}

Error signifies that the previous message sent by the client caused some sort of parsing or processing error on the server.

type FleshlightLaunchFW12Cmd

type FleshlightLaunchFW12Cmd struct {
	// Message ID.
	ID uint32 `json:"Id"`
	// Index used to identify the device.
	DeviceIndex uint32
	// Position to move to, range 0-99.
	Position int
	// Speed to move at, range 0-99.
	Speed int
}

FleshlightLaunchFW12Cmd causes a toy that supports Fleshlight Launch (Firmware Version 1.2) style commands to run whatever event may be related.

type IDCounter

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

IDCounter is a concurrent safe id counter used for message id's.

func (*IDCounter) Generate

func (c *IDCounter) Generate() uint32

Generate creates a new ID.

type IncomingMessage

type IncomingMessage struct {
	Ok    *Empty `json:"Ok,omitempty"`
	Error *Error `json:"Error,omitempty"`
	Test  *Test  `json:"Test,omitempty"`
	Log   *Log   `json:"Log,omitempty"`

	ServerInfo       *ServerInfo `json:"ServerInfo,omitempty"`
	ScanningFinished *Empty      `json:"ScanningFinished,omitempty"`

	DeviceList    *DeviceList `json:"DeviceList,omitempty"`
	DeviceAdded   *Device     `json:"DeviceAdded,omitempty"`
	DeviceRemoved *Device     `json:"DeviceRemoved,omitempty"`
}

IncomingMessage contains all messages a Buttplug server can send.

func (IncomingMessage) Message

func (m IncomingMessage) Message() (id uint32, v interface{})

Message returns the id and message.

type IncomingMessages

type IncomingMessages []IncomingMessage

IncomingMessages list of messages send from a Buttplug server.

type KiirooCmd

type KiirooCmd struct {
	// Message ID.
	ID uint32 `json:"Id"`
	// Index used to identify the device.
	DeviceIndex uint32
	// Command (range [0-4])
	Command int
}

KiirooCmd causes a toy that supports Kiiroo style commands to run whatever event may be related.

type Log

type Log struct {
	// Message ID.
	ID uint32 `json:"Id"`
	// The level of the log message.
	LogLevel string
	// Message
	LogMessage string
}

Log message from the server.

type LovenseCmd

type LovenseCmd struct {
	// Message ID.
	ID uint32 `json:"Id"`
	// Index used to identify the device.
	DeviceIndex uint32
	// Command for Lovense toys. Must be a valid Lovense command accessible
	// on most of their toys. Implementations should check this for
	// validity.
	Command string
}

LovenseCmd causes a toy that supports Lovense style commands to run whatever event may be related.

type OutgoingMessage

type OutgoingMessage struct {
	Ping       *Empty      `json:"Ping,omitempty"`
	Test       *Test       `json:"Test,omitempty"`
	RequestLog *RequestLog `json:"RequestLog,omitempty"`

	RequestServerInfo *RequestServerInfo `json:"RequestServerInfo,omitempty"`

	StartScanning     *Empty `json:"StartScanning,omitempty"`
	StopScanning      *Empty `json:"StopScanning,omitempty"`
	RequestDeviceList *Empty `json:"RequestDeviceList,omitempty"`

	StopDeviceCmd  *Device `json:"StopDeviceCmd,omitempty"`
	StopAllDevices *Empty  `json:"StopAllDevices,omitempty"`

	RawCmd                  *RawCmd                  `json:"RawCmd,omitempty"`
	SingleMotorVibrateCmd   *SingleMotorVibrateCmd   `json:"SingleMotorVibrateCmd,omitempty"`
	KiirooCmd               *KiirooCmd               `json:"KiirooCmd,omitempty"`
	FleshlightLaunchFW12Cmd *FleshlightLaunchFW12Cmd `json:"FleshlightLaunchFW12Cmd,omitempty"`
	LovenseCmd              *LovenseCmd              `json:"LovenseCmd,omitempty"`
	VorzeA10CycloneCmd      *VorzeA10CycloneCmd      `json:"VorzeA10CycloneCmd,omitempty"`
}

OutgoingMessage contains all messages a Buttplug server can receive.

type OutgoingMessages

type OutgoingMessages []OutgoingMessage

OutgoingMessages list of messages send to a Buttplug server.

type RawCmd

type RawCmd struct {
	// Message ID.
	ID uint32 `json:"Id"`
	// Index used to identify the device.
	DeviceIndex uint32
	// Command to execute.
	Command []byte
}

RawCmd used to send a raw byte string to a device.

type Reader

type Reader struct {
	// contains filtered or unexported fields
}

Reader is receives messages from the Receiver subscription.

func (*Reader) Incoming

func (r *Reader) Incoming() <-chan IncomingMessage

Incoming returns a channel of incoming messages.

type Receiver

type Receiver struct {
	// contains filtered or unexported fields
}

Receiver can read Buttplug server messages from a websocket to multiple readers. Readers can subscribe/unsubscribe from receiving messages.

func NewReceiver

func NewReceiver(conn *websocket.Conn, done chan struct{}) *Receiver

NewReceiver creates a Receiver for the given websocket connection. Done channel is closed then receiver is done.

func (*Receiver) Stop

func (rc *Receiver) Stop()

Stop the receiver from sending any messages.

func (*Receiver) Subscribe

func (rc *Receiver) Subscribe() (*Reader, error)

Subscribe creates a new reader that receives messages. A consumer should call the Unsubscribe when it's done with the reader.

func (*Receiver) Unsubscribe

func (rc *Receiver) Unsubscribe(r *Reader)

Unsubscribe removes the readers subscription and will no longer receive messages.

type RequestLog

type RequestLog struct {
	// Message ID.
	ID uint32 `json:"Id"`
	// The highest level of message to receive.
	LogLevel string
}

RequestLog requests that the server send internal log messages.

type RequestServerInfo

type RequestServerInfo struct {
	// The ID of the client message that this reply is in response to.
	ID uint32 `json:"Id"`
	// Name of the client, for the server to use for UI if needed.
	ClientName string
}

RequestServerInfo register with the server, and request info from the server.

type Sender

type Sender struct {
	// contains filtered or unexported fields
}

Sender buffers and sends Buttplug messages over a websocket connection.

func NewSender

func NewSender(conn *websocket.Conn) (b *Sender)

NewSender creates a Sender for the given websocket.

func (*Sender) Send

func (b *Sender) Send(m OutgoingMessage) error

Send a message to the server.

func (*Sender) Stop

func (b *Sender) Stop()

Stop causes the sender to stop sending messages.

type ServerInfo

type ServerInfo struct {
	// The ID of the client message that this reply is in response to.
	ID uint32 `json:"Id"`
	// Name of the server.
	ServerName string
	// Message template version of the server software.
	MessageVersion uint32
	// Major version of the server software.
	MajorVersion uint32
	// Minor version of the server software.
	MinorVersion uint32
	// Build version of the server software.
	BuildVersion uint32
	// Maximum internal for pings from the client, in milliseconds.
	MaxPingTime uint32
}

ServerInfo contains information about the server name (optional), template version, and ping time expectations.

type SingleMotorVibrateCmd

type SingleMotorVibrateCmd struct {
	// Message ID.
	ID uint32 `json:"Id"`
	// Index used to identify the device.
	DeviceIndex uint32
	// Vibration speed, with a range of [0.0-1.0]
	Speed float64
}

SingleMotorVibrateCmd causes a toy that supports vibration to run at a certain speed.

type Test

type Test struct {
	// Message ID.
	ID uint32 `json:"Id"`
	// String to echo back from server.
	TestString string
}

Test message is used for development and testing purposes. Sending a Test message with a string to the server will cause the server to return a Test message. If the string is "Error", the server will return an error message instead.

type VorzeA10CycloneCmd

type VorzeA10CycloneCmd struct {
	// Message ID.
	ID uint32 `json:"Id"`
	// Index used to identify the device.
	DeviceIndex uint32
	// Rotation speed command for the Cyclone.
	Speed int
	// True for clockwise rotation (in relation to device facing user),
	// false for Counter-clockwise
	Clockwise bool
}

VorzeA10CycloneCmd causes a toy that supports VorzeA10Cyclone style commands to run whatever event may be related.

Jump to

Keyboard shortcuts

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