vibrate method
Implementation
Future<void> vibrate(VibrateCommand command) async {
if (messageAttributes.scalarCmd == null ||
!messageAttributes.scalarCmd!.any((element) => element.actuatorType == ActuatorType.Vibrate)) {
throw ButtplugClientDeviceException("$name ($displayName) does not support vibration commands");
}
// Rebuild vibration command as scalar command
var vibeCount =
messageAttributes.scalarCmd!.where((element) => element.actuatorType == ActuatorType.Vibrate).length;
var scalarMap = <int, ScalarComponent>{};
command.asMap(vibeCount).forEach((key, value) {
scalarMap[key] = ScalarComponent(value.speed, ActuatorType.Vibrate);
});
return await scalar(ScalarCommand.setMap(scalarMap));
}