schema

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2025 License: ISC Imports: 6 Imported by: 0

Documentation

Overview

Package schema contains the Buttplug message schema for version 2.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsInternalMessage

func IsInternalMessage(m Message) bool

IsInternalMessage returns whether the message is an internal-only message.

Types

type BatteryLevelCmdMessage

type BatteryLevelCmdMessage struct {
	// ID: user-set id for the message. 0 denotes system message and is
	// reserved.
	ID ClientID `json:"Id"`
	// DeviceIndex: index used for referencing the device in device messages.
	DeviceIndex DeviceIndex `json:"DeviceIndex"`
}

BatteryLevelCmdMessage: requests that a BatteryLevel be retreived.

func (*BatteryLevelCmdMessage) ClientID

func (b *BatteryLevelCmdMessage) ClientID() ClientID

ClientID implements ClientMessage

func (*BatteryLevelCmdMessage) LogValue

func (b *BatteryLevelCmdMessage) LogValue() slog.Value

LogValue implements slog.LogValuer.

func (*BatteryLevelCmdMessage) Type

Type returns MessageTypeBatteryLevelCmd.

func (*BatteryLevelCmdMessage) WithID

WithID implements ClientMessage.

type BatteryLevelReadingMessage

type BatteryLevelReadingMessage struct {
	// ID: user-set id for the message. 0 denotes system message and is
	// reserved.
	ID ClientID `json:"Id"`
	// DeviceIndex: index used for referencing the device in device messages.
	DeviceIndex DeviceIndex `json:"DeviceIndex"`
	// BatteryLevel: battery Level.
	BatteryLevel float64 `json:"BatteryLevel"`
}

BatteryLevelReadingMessage: returns a BatteryLevel read from a device.

func (*BatteryLevelReadingMessage) ClientID

func (b *BatteryLevelReadingMessage) ClientID() ClientID

ClientID implements ClientMessage

func (*BatteryLevelReadingMessage) LogValue

func (b *BatteryLevelReadingMessage) LogValue() slog.Value

LogValue implements slog.LogValuer.

func (*BatteryLevelReadingMessage) Type

Type returns MessageTypeBatteryLevelReading.

func (*BatteryLevelReadingMessage) WithID

WithID implements ClientMessage.

type ClientID

type ClientID int

ClientID: user-set id for the message. 0 denotes system message and is reserved.

type ClientMessage

type ClientMessage interface {
	Message
	// ClientID returns the ID field of the message.
	ClientID() ClientID
	// WithID sets the ID field of the shallow-copied message and returns the modified message.
	WithID(id ClientID) ClientMessage
	// contains filtered or unexported methods
}

ClientMessage represents a message that can be sent from the client to the server. It extends Message with a way to set the client ID to be used when sending the message.

The following messages are defined:

type Device added in v0.0.6

type Device struct {
	// DeviceName: name of the device.
	DeviceName DeviceName `json:"DeviceName"`
	// DeviceIndex: index used for referencing the device in device messages.
	DeviceIndex DeviceIndex `json:"DeviceIndex"`
	// DeviceMessages: a list of the messages a device will accept on this
	// server implementation.
	DeviceMessages DeviceMessages `json:"DeviceMessages"`
}

type DeviceAddedMessage

type DeviceAddedMessage struct {
	// ID: used for non-direct-reply messages that can only be sent from server
	// to client, using the reserved system message Id of 0.
	ID SystemID `json:"Id"`
	// DeviceName: name of the device.
	DeviceName DeviceName `json:"DeviceName"`
	// DeviceIndex: index used for referencing the device in device messages.
	DeviceIndex DeviceIndex `json:"DeviceIndex"`
	// DeviceMessages: a list of the messages a device will accept on this
	// server implementation.
	DeviceMessages DeviceMessages `json:"DeviceMessages"`
}

DeviceAddedMessage: notifies client that a device of a certain type has been added to the server.

func (*DeviceAddedMessage) LogValue

func (d *DeviceAddedMessage) LogValue() slog.Value

LogValue implements slog.LogValuer.

func (*DeviceAddedMessage) Type

func (d *DeviceAddedMessage) Type() MessageType

Type returns MessageTypeDeviceAdded.

type DeviceIndex

type DeviceIndex int

DeviceIndex: index used for referencing the device in device messages.

type DeviceListMessage

type DeviceListMessage struct {
	// ID: user-set id for the message. 0 denotes system message and is
	// reserved.
	ID ClientID `json:"Id"`
	// Devices: array of device ids and names.
	Devices []Device `json:"Devices"`
}

DeviceListMessage: list of all available devices known to the system.

func (*DeviceListMessage) ClientID

func (d *DeviceListMessage) ClientID() ClientID

ClientID implements ClientMessage

func (*DeviceListMessage) LogValue

func (d *DeviceListMessage) LogValue() slog.Value

LogValue implements slog.LogValuer.

func (*DeviceListMessage) Type

func (d *DeviceListMessage) Type() MessageType

Type returns MessageTypeDeviceList.

func (*DeviceListMessage) WithID

WithID implements ClientMessage.

type DeviceMessages

type DeviceMessages struct {
	// BatteryLevelCmd: attributes for device message that have no attributes.
	BatteryLevelCmd ptr.Optional[NullMessageAttributes] `json:"BatteryLevelCmd,omitzero"`
	// LinearCmd: attributes for device messages.
	LinearCmd ptr.Optional[GenericMessageAttributes] `json:"LinearCmd,omitzero"`
	// RSSILevelCmd: attributes for device message that have no attributes.
	RSSILevelCmd ptr.Optional[NullMessageAttributes] `json:"RSSILevelCmd,omitzero"`
	// RawReadCmd: attributes for raw device messages.
	RawReadCmd ptr.Optional[RawMessageAttributes] `json:"RawReadCmd,omitzero"`
	// RawSubscribeCmd: attributes for raw device messages.
	RawSubscribeCmd ptr.Optional[RawMessageAttributes] `json:"RawSubscribeCmd,omitzero"`
	// RawUnsubscribeCmd: attributes for raw device messages.
	RawUnsubscribeCmd ptr.Optional[RawMessageAttributes] `json:"RawUnsubscribeCmd,omitzero"`
	// RawWriteCmd: attributes for raw device messages.
	RawWriteCmd ptr.Optional[RawMessageAttributes] `json:"RawWriteCmd,omitzero"`
	// RotateCmd: attributes for device messages.
	RotateCmd ptr.Optional[GenericMessageAttributes] `json:"RotateCmd,omitzero"`
	// StopDeviceCmd: attributes for device message that have no attributes.
	StopDeviceCmd ptr.Optional[NullMessageAttributes] `json:"StopDeviceCmd,omitzero"`
	// VibrateCmd: attributes for device messages.
	VibrateCmd ptr.Optional[GenericMessageAttributes] `json:"VibrateCmd,omitzero"`
}

DeviceMessages: a list of the messages a device will accept on this server implementation.

type DeviceName

type DeviceName string

DeviceName: name of the device.

type DeviceRemovedMessage

type DeviceRemovedMessage struct {
	// ID: used for non-direct-reply messages that can only be sent from server
	// to client, using the reserved system message Id of 0.
	ID SystemID `json:"Id"`
	// DeviceIndex: index used for referencing the device in device messages.
	DeviceIndex DeviceIndex `json:"DeviceIndex"`
}

DeviceRemovedMessage: notifies client that a device of a certain type has been removed from the server.

func (*DeviceRemovedMessage) LogValue

func (d *DeviceRemovedMessage) LogValue() slog.Value

LogValue implements slog.LogValuer.

func (*DeviceRemovedMessage) Type

Type returns MessageTypeDeviceRemoved.

type ErrorMessage

type ErrorMessage struct {
	// ID: user-set id for the message. 0 denotes system message and is
	// reserved.
	ID           ServerID `json:"Id"`
	ErrorMessage string   `json:"ErrorMessage"`
	ErrorCode    float64  `json:"ErrorCode"`
}

ErrorMessage: signifies the server encountered an error while processing the message indicated by the id.

func (*ErrorMessage) LogValue

func (e *ErrorMessage) LogValue() slog.Value

LogValue implements slog.LogValuer.

func (*ErrorMessage) ServerID

func (e *ErrorMessage) ServerID() ServerID

ServerID implements ServerMessage

func (*ErrorMessage) Type

func (e *ErrorMessage) Type() MessageType

Type returns MessageTypeError.

type FeatureCount

type FeatureCount int

FeatureCount: number of features on device.

type GenericMessageAttributes

type GenericMessageAttributes struct {
	// FeatureCount: number of features on device.
	FeatureCount ptr.Optional[FeatureCount] `json:"FeatureCount,omitzero"`
	// StepCount: specifies granularity of each feature on the device.
	StepCount StepCount `json:"StepCount,omitzero"`
}

GenericMessageAttributes: attributes for device messages.

type InternalMessage

type InternalMessage struct{}

InternalMessage is a special type that the library uses for internal-only messages. Messages of this type were never emitted from the server.

func (InternalMessage) MarshalJSON

func (m InternalMessage) MarshalJSON() ([]byte, error)

MarshalJSON returns an error because internal messages cannot be marshaled.

func (InternalMessage) Type

func (m InternalMessage) Type() MessageType

Type returns an empty string for internal messages.

type LinearCmdMessage

type LinearCmdMessage struct {
	// ID: user-set id for the message. 0 denotes system message and is
	// reserved.
	ID ClientID `json:"Id"`
	// DeviceIndex: index used for referencing the device in device messages.
	DeviceIndex DeviceIndex `json:"DeviceIndex"`
	// Vectors: device linear movement times (milliseconds) and positions
	// (floating point, 0 < x < 1) keyed on linear actuator number, stepping
	// will be device specific.
	Vectors []Vector `json:"Vectors"`
}

LinearCmdMessage: sends a linear movement command to a device that supports linear movements.

func (*LinearCmdMessage) ClientID

func (l *LinearCmdMessage) ClientID() ClientID

ClientID implements ClientMessage

func (*LinearCmdMessage) LogValue

func (l *LinearCmdMessage) LogValue() slog.Value

LogValue implements slog.LogValuer.

func (*LinearCmdMessage) Type

func (l *LinearCmdMessage) Type() MessageType

Type returns MessageTypeLinearCmd.

func (*LinearCmdMessage) WithID

func (l *LinearCmdMessage) WithID(id ClientID) ClientMessage

WithID implements ClientMessage.

type MessageType

type MessageType string

MessageType is the type string used to identify a buttplug.io message from the wire.

const (
	// MessageTypeBatteryLevelCmd is the type string for a [BatteryLevelCmdMessage].
	MessageTypeBatteryLevelCmd MessageType = "BatteryLevelCmd"
	// MessageTypeBatteryLevelReading is the type string for a [BatteryLevelReadingMessage].
	MessageTypeBatteryLevelReading MessageType = "BatteryLevelReading"
	// MessageTypeDeviceAdded is the type string for a [DeviceAddedMessage].
	MessageTypeDeviceAdded MessageType = "DeviceAdded"
	// MessageTypeDeviceList is the type string for a [DeviceListMessage].
	MessageTypeDeviceList MessageType = "DeviceList"
	// MessageTypeDeviceRemoved is the type string for a [DeviceRemovedMessage].
	MessageTypeDeviceRemoved MessageType = "DeviceRemoved"
	// MessageTypeError is the type string for a [ErrorMessage].
	MessageTypeError MessageType = "Error"
	// MessageTypeLinearCmd is the type string for a [LinearCmdMessage].
	MessageTypeLinearCmd MessageType = "LinearCmd"
	// MessageTypeOK is the type string for a [OKMessage].
	MessageTypeOK MessageType = "Ok"
	// MessageTypePing is the type string for a [PingMessage].
	MessageTypePing MessageType = "Ping"
	// MessageTypeRSSILevelCmd is the type string for a [RSSILevelCmdMessage].
	MessageTypeRSSILevelCmd MessageType = "RSSILevelCmd"
	// MessageTypeRSSILevelReading is the type string for a [RSSILevelReadingMessage].
	MessageTypeRSSILevelReading MessageType = "RSSILevelReading"
	// MessageTypeRawReadCmd is the type string for a [RawReadCmdMessage].
	MessageTypeRawReadCmd MessageType = "RawReadCmd"
	// MessageTypeRawReading is the type string for a [RawReadingMessage].
	MessageTypeRawReading MessageType = "RawReading"
	// MessageTypeRawSubscribeCmd is the type string for a [RawSubscribeCmdMessage].
	MessageTypeRawSubscribeCmd MessageType = "RawSubscribeCmd"
	// MessageTypeRawUnsubscribeCmd is the type string for a [RawUnsubscribeCmdMessage].
	MessageTypeRawUnsubscribeCmd MessageType = "RawUnsubscribeCmd"
	// MessageTypeRawWriteCmd is the type string for a [RawWriteCmdMessage].
	MessageTypeRawWriteCmd MessageType = "RawWriteCmd"
	// MessageTypeRequestDeviceList is the type string for a [RequestDeviceListMessage].
	MessageTypeRequestDeviceList MessageType = "RequestDeviceList"
	// MessageTypeRequestLog is the type string for a [RequestLogMessage].
	MessageTypeRequestLog MessageType = "RequestLog"
	// MessageTypeRequestServerInfo is the type string for a [RequestServerInfoMessage].
	MessageTypeRequestServerInfo MessageType = "RequestServerInfo"
	// MessageTypeRotateCmd is the type string for a [RotateCmdMessage].
	MessageTypeRotateCmd MessageType = "RotateCmd"
	// MessageTypeScanningFinished is the type string for a [ScanningFinishedMessage].
	MessageTypeScanningFinished MessageType = "ScanningFinished"
	// MessageTypeServerInfo is the type string for a [ServerInfoMessage].
	MessageTypeServerInfo MessageType = "ServerInfo"
	// MessageTypeStartScanning is the type string for a [StartScanningMessage].
	MessageTypeStartScanning MessageType = "StartScanning"
	// MessageTypeStopAllDevices is the type string for a [StopAllDevicesMessage].
	MessageTypeStopAllDevices MessageType = "StopAllDevices"
	// MessageTypeStopDeviceCmd is the type string for a [StopDeviceCmdMessage].
	MessageTypeStopDeviceCmd MessageType = "StopDeviceCmd"
	// MessageTypeStopScanning is the type string for a [StopScanningMessage].
	MessageTypeStopScanning MessageType = "StopScanning"
	// MessageTypeVibrateCmd is the type string for a [VibrateCmdMessage].
	MessageTypeVibrateCmd MessageType = "VibrateCmd"
)

All defined message types.

type NullMessageAttributes

type NullMessageAttributes struct{}

NullMessageAttributes: attributes for device message that have no attributes.

type OKMessage

type OKMessage struct {
	// ID: user-set id for the message. 0 denotes system message and is
	// reserved.
	ID ClientID `json:"Id"`
}

OKMessage: signifies successful processing of the message indicated by the id.

func (*OKMessage) ClientID

func (o *OKMessage) ClientID() ClientID

ClientID implements ClientMessage

func (*OKMessage) LogValue

func (o *OKMessage) LogValue() slog.Value

LogValue implements slog.LogValuer.

func (*OKMessage) Type

func (o *OKMessage) Type() MessageType

Type returns MessageTypeOK.

func (*OKMessage) WithID

func (o *OKMessage) WithID(id ClientID) ClientMessage

WithID implements ClientMessage.

type Payload

type Payload []Message

Payload is a list of messages sent from the buttplug.io websocket server. Use this type to parse each message in the payload.

func (Payload) LogValue

func (p Payload) LogValue() slog.Value

LogValue implements slog.LogValuer.

func (Payload) MarshalJSONTo

func (p Payload) MarshalJSONTo(encoder *jsontext.Encoder) error

MarshalJSONTo writes the payload as the JSON websocket wire protocol.

func (*Payload) UnmarshalJSONFrom

func (p *Payload) UnmarshalJSONFrom(decoder *jsontext.Decoder) error

UnmarshalJSONFrom implements json.UnmarshalerFrom. It consumes one full array of messages from the given JSON decoder.

type PingMessage

type PingMessage struct {
	// ID: user-set id for the message. 0 denotes system message and is
	// reserved.
	ID ClientID `json:"Id"`
}

PingMessage: connection keep-alive message.

func (*PingMessage) ClientID

func (p *PingMessage) ClientID() ClientID

ClientID implements ClientMessage

func (*PingMessage) LogValue

func (p *PingMessage) LogValue() slog.Value

LogValue implements slog.LogValuer.

func (*PingMessage) Type

func (p *PingMessage) Type() MessageType

Type returns MessageTypePing.

func (*PingMessage) WithID

func (p *PingMessage) WithID(id ClientID) ClientMessage

WithID implements ClientMessage.

type RSSILevelCmdMessage

type RSSILevelCmdMessage struct {
	// ID: user-set id for the message. 0 denotes system message and is
	// reserved.
	ID ClientID `json:"Id"`
	// DeviceIndex: index used for referencing the device in device messages.
	DeviceIndex DeviceIndex `json:"DeviceIndex"`
}

RSSILevelCmdMessage: requests that a RSSI level be retreived.

func (*RSSILevelCmdMessage) ClientID

func (r *RSSILevelCmdMessage) ClientID() ClientID

ClientID implements ClientMessage

func (*RSSILevelCmdMessage) LogValue

func (r *RSSILevelCmdMessage) LogValue() slog.Value

LogValue implements slog.LogValuer.

func (*RSSILevelCmdMessage) Type

func (r *RSSILevelCmdMessage) Type() MessageType

Type returns MessageTypeRSSILevelCmd.

func (*RSSILevelCmdMessage) WithID

WithID implements ClientMessage.

type RSSILevelReadingMessage

type RSSILevelReadingMessage struct {
	// ID: user-set id for the message. 0 denotes system message and is
	// reserved.
	ID ClientID `json:"Id"`
	// DeviceIndex: index used for referencing the device in device messages.
	DeviceIndex DeviceIndex `json:"DeviceIndex"`
	// RSSILevel: RSSI Level.
	RSSILevel float64 `json:"RSSILevel"`
}

RSSILevelReadingMessage: returns a BatteryLevel read from a device.

func (*RSSILevelReadingMessage) ClientID

func (r *RSSILevelReadingMessage) ClientID() ClientID

ClientID implements ClientMessage

func (*RSSILevelReadingMessage) LogValue

func (r *RSSILevelReadingMessage) LogValue() slog.Value

LogValue implements slog.LogValuer.

func (*RSSILevelReadingMessage) Type

Type returns MessageTypeRSSILevelReading.

func (*RSSILevelReadingMessage) WithID

WithID implements ClientMessage.

type RawMessageAttributes

type RawMessageAttributes struct {
	Endpoints []string `json:"Endpoints,omitzero"`
}

RawMessageAttributes: attributes for raw device messages.

type RawReadCmdMessage

type RawReadCmdMessage struct {
	// ID: user-set id for the message. 0 denotes system message and is
	// reserved.
	ID ClientID `json:"Id"`
	// Endpoint (from device config file) from which the data was retrieved.
	Endpoint string `json:"Endpoint"`
	// DeviceIndex: index used for referencing the device in device messages.
	DeviceIndex DeviceIndex `json:"DeviceIndex"`
	// Length: amount of data to read from device, 0 to exhaust whatever is in
	// immediate buffer.
	Length int `json:"Length"`
	// WaitForData: if true, then wait until Length amount of data is available.
	WaitForData bool `json:"WaitForData"`
}

RawReadCmdMessage: request a raw byte array from a device. Should only be used for testing/development.

func (*RawReadCmdMessage) ClientID

func (r *RawReadCmdMessage) ClientID() ClientID

ClientID implements ClientMessage

func (*RawReadCmdMessage) LogValue

func (r *RawReadCmdMessage) LogValue() slog.Value

LogValue implements slog.LogValuer.

func (*RawReadCmdMessage) Type

func (r *RawReadCmdMessage) Type() MessageType

Type returns MessageTypeRawReadCmd.

func (*RawReadCmdMessage) WithID

WithID implements ClientMessage.

type RawReadingMessage

type RawReadingMessage struct {
	// ID: user-set id for the message. 0 denotes system message and is
	// reserved.
	ID ServerID `json:"Id"`
	// Endpoint (from device config file) from which the data was retrieved.
	Endpoint string `json:"Endpoint"`
	// DeviceIndex: index used for referencing the device in device messages.
	DeviceIndex DeviceIndex `json:"DeviceIndex"`
	// Data: raw byte string received from device.
	Data []int `json:"Data"`
}

RawReadingMessage: raw byte array received from a device. Should only be used for testing/development.

func (*RawReadingMessage) LogValue

func (r *RawReadingMessage) LogValue() slog.Value

LogValue implements slog.LogValuer.

func (*RawReadingMessage) ServerID

func (r *RawReadingMessage) ServerID() ServerID

ServerID implements ServerMessage

func (*RawReadingMessage) Type

func (r *RawReadingMessage) Type() MessageType

Type returns MessageTypeRawReading.

type RawSubscribeCmdMessage

type RawSubscribeCmdMessage struct {
	// ID: user-set id for the message. 0 denotes system message and is
	// reserved.
	ID ClientID `json:"Id"`
	// Endpoint (from device config file) from which the data was retrieved.
	Endpoint string `json:"Endpoint"`
	// DeviceIndex: index used for referencing the device in device messages.
	DeviceIndex DeviceIndex `json:"DeviceIndex"`
}

RawSubscribeCmdMessage: subscribe to an endpoint on a device to receive raw info back.

func (*RawSubscribeCmdMessage) ClientID

func (r *RawSubscribeCmdMessage) ClientID() ClientID

ClientID implements ClientMessage

func (*RawSubscribeCmdMessage) LogValue

func (r *RawSubscribeCmdMessage) LogValue() slog.Value

LogValue implements slog.LogValuer.

func (*RawSubscribeCmdMessage) Type

Type returns MessageTypeRawSubscribeCmd.

func (*RawSubscribeCmdMessage) WithID

WithID implements ClientMessage.

type RawUnsubscribeCmdMessage

type RawUnsubscribeCmdMessage struct {
	// ID: user-set id for the message. 0 denotes system message and is
	// reserved.
	ID ClientID `json:"Id"`
	// Endpoint (from device config file) from which the data was retrieved.
	Endpoint string `json:"Endpoint"`
	// DeviceIndex: index used for referencing the device in device messages.
	DeviceIndex DeviceIndex `json:"DeviceIndex"`
}

RawUnsubscribeCmdMessage: unsubscribe to an endpoint on a device.

func (*RawUnsubscribeCmdMessage) ClientID

func (r *RawUnsubscribeCmdMessage) ClientID() ClientID

ClientID implements ClientMessage

func (*RawUnsubscribeCmdMessage) LogValue

func (r *RawUnsubscribeCmdMessage) LogValue() slog.Value

LogValue implements slog.LogValuer.

func (*RawUnsubscribeCmdMessage) Type

Type returns MessageTypeRawUnsubscribeCmd.

func (*RawUnsubscribeCmdMessage) WithID

WithID implements ClientMessage.

type RawWriteCmdMessage

type RawWriteCmdMessage struct {
	// ID: user-set id for the message. 0 denotes system message and is
	// reserved.
	ID ClientID `json:"Id"`
	// Endpoint (from device config file) to send command to.
	Endpoint string `json:"Endpoint"`
	// DeviceIndex: index used for referencing the device in device messages.
	DeviceIndex DeviceIndex `json:"DeviceIndex"`
	// Data: raw byte string to send to device.
	Data []int `json:"Data"`
	// WriteWithResponse: if true, BLE writes will use WriteWithResponse.
	// Value ignored for all other types.
	WriteWithResponse bool `json:"WriteWithResponse"`
}

RawWriteCmdMessage: sends a raw byte array to a device. Should only be used for testing/development.

func (*RawWriteCmdMessage) ClientID

func (r *RawWriteCmdMessage) ClientID() ClientID

ClientID implements ClientMessage

func (*RawWriteCmdMessage) LogValue

func (r *RawWriteCmdMessage) LogValue() slog.Value

LogValue implements slog.LogValuer.

func (*RawWriteCmdMessage) Type

func (r *RawWriteCmdMessage) Type() MessageType

Type returns MessageTypeRawWriteCmd.

func (*RawWriteCmdMessage) WithID

WithID implements ClientMessage.

type RequestDeviceListMessage

type RequestDeviceListMessage struct {
	// ID: user-set id for the message. 0 denotes system message and is
	// reserved.
	ID ClientID `json:"Id"`
}

RequestDeviceListMessage: request for the server to send a list of devices to the client.

func (*RequestDeviceListMessage) ClientID

func (r *RequestDeviceListMessage) ClientID() ClientID

ClientID implements ClientMessage

func (*RequestDeviceListMessage) LogValue

func (r *RequestDeviceListMessage) LogValue() slog.Value

LogValue implements slog.LogValuer.

func (*RequestDeviceListMessage) Type

Type returns MessageTypeRequestDeviceList.

func (*RequestDeviceListMessage) WithID

WithID implements ClientMessage.

type RequestLogLevel

type RequestLogLevel string

LogLevel: maximum level of log message to receive.

const (
	RequestLogLevelOff   RequestLogLevel = "Off"
	RequestLogLevelFatal RequestLogLevel = "Fatal"
	RequestLogLevelError RequestLogLevel = "Error"
	RequestLogLevelWarn  RequestLogLevel = "Warn"
	RequestLogLevelInfo  RequestLogLevel = "Info"
	RequestLogLevelDebug RequestLogLevel = "Debug"
	RequestLogLevelTrace RequestLogLevel = "Trace"
)

Enumeration values for RequestLogLevel of [RequestLog].

type RequestLogMessage

type RequestLogMessage struct {
	// ID: user-set id for the message. 0 denotes system message and is
	// reserved.
	ID ClientID `json:"Id"`
	// LogLevel: maximum level of log message to receive.
	LogLevel RequestLogLevel `json:"LogLevel"`
}

RequestLogMessage: request for server to stream log messages of a certain level to client.

func (*RequestLogMessage) ClientID

func (r *RequestLogMessage) ClientID() ClientID

ClientID implements ClientMessage

func (*RequestLogMessage) LogValue

func (r *RequestLogMessage) LogValue() slog.Value

LogValue implements slog.LogValuer.

func (*RequestLogMessage) Type

func (r *RequestLogMessage) Type() MessageType

Type returns MessageTypeRequestLog.

func (*RequestLogMessage) WithID

WithID implements ClientMessage.

type RequestServerInfoMessage

type RequestServerInfoMessage struct {
	// ID: user-set id for the message. 0 denotes system message and is
	// reserved.
	ID ClientID `json:"Id"`
	// ClientName: name of the client software.
	ClientName string `json:"ClientName"`
	// MessageVersion: message template version of the client software.
	MessageVersion int `json:"MessageVersion"`
}

RequestServerInfoMessage: request server version, and relay client name.

func (*RequestServerInfoMessage) ClientID

func (r *RequestServerInfoMessage) ClientID() ClientID

ClientID implements ClientMessage

func (*RequestServerInfoMessage) LogValue

func (r *RequestServerInfoMessage) LogValue() slog.Value

LogValue implements slog.LogValuer.

func (*RequestServerInfoMessage) Type

Type returns MessageTypeRequestServerInfo.

func (*RequestServerInfoMessage) WithID

WithID implements ClientMessage.

type RotateCmdMessage

type RotateCmdMessage struct {
	// ID: user-set id for the message. 0 denotes system message and is
	// reserved.
	ID ClientID `json:"Id"`
	// DeviceIndex: index used for referencing the device in device messages.
	DeviceIndex DeviceIndex `json:"DeviceIndex"`
	// Rotations: device rotation speeds (floating point, 0 < x < 1) keyed on
	// rotator number, stepping will be device specific.
	Rotations []Rotation `json:"Rotations"`
}

RotateCmdMessage: sends a rotate command to a device that supports rotation.

func (*RotateCmdMessage) ClientID

func (r *RotateCmdMessage) ClientID() ClientID

ClientID implements ClientMessage

func (*RotateCmdMessage) LogValue

func (r *RotateCmdMessage) LogValue() slog.Value

LogValue implements slog.LogValuer.

func (*RotateCmdMessage) Type

func (r *RotateCmdMessage) Type() MessageType

Type returns MessageTypeRotateCmd.

func (*RotateCmdMessage) WithID

func (r *RotateCmdMessage) WithID(id ClientID) ClientMessage

WithID implements ClientMessage.

type Rotation added in v0.0.6

type Rotation struct {
	// Index: rotator number.
	Index int `json:"Index"`
	// Speed: rotation speed (floating point, 0 < x < 1), stepping will be
	// device specific.
	Speed float64 `json:"Speed"`
	// Clockwise: rotation direction (boolean). Not all devices have a concept
	// of actual clockwise.
	Clockwise bool `json:"Clockwise"`
}

type ScanningFinishedMessage

type ScanningFinishedMessage struct {
	// ID: used for non-direct-reply messages that can only be sent from server
	// to client, using the reserved system message Id of 0.
	ID SystemID `json:"Id"`
}

ScanningFinishedMessage: server notification to client that scanning has ended.

func (*ScanningFinishedMessage) LogValue

func (s *ScanningFinishedMessage) LogValue() slog.Value

LogValue implements slog.LogValuer.

func (*ScanningFinishedMessage) Type

Type returns MessageTypeScanningFinished.

type ServerID

type ServerID int

ServerID: user-set id for the message. 0 denotes system message and is reserved.

type ServerInfoMessage

type ServerInfoMessage struct {
	// ID: user-set id for the message. 0 denotes system message and is
	// reserved.
	ID ClientID `json:"Id"`
	// MessageVersion: message template version of the server software.
	MessageVersion int `json:"MessageVersion"`
	// MaxPingTime: maximum time (in milliseconds) the server will wait between
	// ping messages from client before shutting down.
	MaxPingTime int `json:"MaxPingTime"`
	// ServerName: name of the server. Can be 0-length.
	ServerName string `json:"ServerName"`
}

ServerInfoMessage: server version information, in Major.Minor.Build format.

func (*ServerInfoMessage) ClientID

func (s *ServerInfoMessage) ClientID() ClientID

ClientID implements ClientMessage

func (*ServerInfoMessage) LogValue

func (s *ServerInfoMessage) LogValue() slog.Value

LogValue implements slog.LogValuer.

func (*ServerInfoMessage) Type

func (s *ServerInfoMessage) Type() MessageType

Type returns MessageTypeServerInfo.

func (*ServerInfoMessage) WithID

WithID implements ClientMessage.

type ServerMessage

type ServerMessage interface {
	Message
	// ServerID returns the ID field of the message.
	ServerID() ServerID
	// contains filtered or unexported methods
}

ServerMessage represents a message that can be sent from the server to the client. It extends Message.

The following messages are defined:

type SpeedsItem

type SpeedsItem struct {
	// Index: vibrator number.
	Index int `json:"Index"`
	// Speed: vibration speed (floating point, 0 < x < 1), stepping will be
	// device specific.
	Speed float64 `json:"Speed"`
}

type StartScanningMessage

type StartScanningMessage struct {
	// ID: user-set id for the message. 0 denotes system message and is
	// reserved.
	ID ClientID `json:"Id"`
}

StartScanningMessage: request for the server to start scanning for new devices.

func (*StartScanningMessage) ClientID

func (s *StartScanningMessage) ClientID() ClientID

ClientID implements ClientMessage

func (*StartScanningMessage) LogValue

func (s *StartScanningMessage) LogValue() slog.Value

LogValue implements slog.LogValuer.

func (*StartScanningMessage) Type

Type returns MessageTypeStartScanning.

func (*StartScanningMessage) WithID

WithID implements ClientMessage.

type StepCount

type StepCount []int

StepCount: specifies granularity of each feature on the device.

type StopAllDevicesMessage

type StopAllDevicesMessage struct {
	// ID: user-set id for the message. 0 denotes system message and is
	// reserved.
	ID ClientID `json:"Id"`
}

StopAllDevicesMessage: stops all actions currently being taken by all connected devices.

func (*StopAllDevicesMessage) ClientID

func (s *StopAllDevicesMessage) ClientID() ClientID

ClientID implements ClientMessage

func (*StopAllDevicesMessage) LogValue

func (s *StopAllDevicesMessage) LogValue() slog.Value

LogValue implements slog.LogValuer.

func (*StopAllDevicesMessage) Type

Type returns MessageTypeStopAllDevices.

func (*StopAllDevicesMessage) WithID

WithID implements ClientMessage.

type StopDeviceCmdMessage

type StopDeviceCmdMessage struct {
	// ID: user-set id for the message. 0 denotes system message and is
	// reserved.
	ID ClientID `json:"Id"`
	// DeviceIndex: index used for referencing the device in device messages.
	DeviceIndex DeviceIndex `json:"DeviceIndex"`
}

StopDeviceCmdMessage: stops the all actions currently being taken by a device.

func (*StopDeviceCmdMessage) ClientID

func (s *StopDeviceCmdMessage) ClientID() ClientID

ClientID implements ClientMessage

func (*StopDeviceCmdMessage) LogValue

func (s *StopDeviceCmdMessage) LogValue() slog.Value

LogValue implements slog.LogValuer.

func (*StopDeviceCmdMessage) Type

Type returns MessageTypeStopDeviceCmd.

func (*StopDeviceCmdMessage) WithID

WithID implements ClientMessage.

type StopScanningMessage

type StopScanningMessage struct {
	// ID: user-set id for the message. 0 denotes system message and is
	// reserved.
	ID ClientID `json:"Id"`
}

StopScanningMessage: request for the server to stop scanning for new devices.

func (*StopScanningMessage) ClientID

func (s *StopScanningMessage) ClientID() ClientID

ClientID implements ClientMessage

func (*StopScanningMessage) LogValue

func (s *StopScanningMessage) LogValue() slog.Value

LogValue implements slog.LogValuer.

func (*StopScanningMessage) Type

func (s *StopScanningMessage) Type() MessageType

Type returns MessageTypeStopScanning.

func (*StopScanningMessage) WithID

WithID implements ClientMessage.

type SystemID

type SystemID int

SystemID: used for non-direct-reply messages that can only be sent from server to client, using the reserved system message Id of 0.

type Vector added in v0.0.6

type Vector struct {
	// Index: linear actuator number.
	Index int `json:"Index"`
	// Duration: linear movement time in milliseconds.
	Duration float64 `json:"Duration"`
	// Position: linear movement position (floating point, 0 < x < 1), stepping
	// will be device specific.
	Position float64 `json:"Position"`
}

type VibrateCmdMessage

type VibrateCmdMessage struct {
	// ID: user-set id for the message. 0 denotes system message and is
	// reserved.
	ID ClientID `json:"Id"`
	// DeviceIndex: index used for referencing the device in device messages.
	DeviceIndex DeviceIndex `json:"DeviceIndex"`
	// Speeds: device vibration speeds (floating point, 0 < x < 1) keyed on
	// vibrator number, stepping will be device specific.
	Speeds []SpeedsItem `json:"Speeds"`
}

VibrateCmdMessage: sends a vibrate command to a device that supports vibration.

func (*VibrateCmdMessage) ClientID

func (v *VibrateCmdMessage) ClientID() ClientID

ClientID implements ClientMessage

func (*VibrateCmdMessage) LogValue

func (v *VibrateCmdMessage) LogValue() slog.Value

LogValue implements slog.LogValuer.

func (*VibrateCmdMessage) Type

func (v *VibrateCmdMessage) Type() MessageType

Type returns MessageTypeVibrateCmd.

func (*VibrateCmdMessage) WithID

WithID implements ClientMessage.

Jump to

Keyboard shortcuts

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