/// <summary> /// Initializes a new instance of the <see cref="ButtplugClientDevice"/> class, using /// discrete parameters. /// </summary> /// <param name="aIndex">The device index.</param> /// <param name="aName">The device name.</param> /// <param name="aMessages">The device allowed message list, with corresponding attributes.</param> public ButtplugClientDevice(IButtplugLogManager aLogManager, ButtplugClient aOwningClient, Func <ButtplugClientDevice, ButtplugDeviceMessage, CancellationToken, Task> aSendClosure, uint aIndex, string aName, Dictionary <string, MessageAttributes> aMessages) { ButtplugUtils.ArgumentNotNull(aLogManager, nameof(aLogManager)); ButtplugUtils.ArgumentNotNull(aOwningClient, nameof(aOwningClient)); ButtplugUtils.ArgumentNotNull(aSendClosure, nameof(aSendClosure)); _bpLogger = aLogManager.GetLogger(GetType()); _owningClient = aOwningClient; _sendClosure = aSendClosure; Index = aIndex; Name = aName; AllowedMessages = new Dictionary <Type, MessageAttributes>(); foreach (var msg in aMessages) { var msgType = ButtplugUtils.GetMessageType(msg.Key); if (msgType == null) { throw new ButtplugDeviceException($"Message type {msg.Key} does not exist."); } AllowedMessages[msgType] = msg.Value; } }
/// <summary> /// Initializes a new instance of the <see cref="ButtplugClientDevice"/> class, using /// information received via a DeviceList, DeviceAdded, or DeviceRemoved message from the server. /// </summary> /// <param name="aDevInfo"> /// A B******g protocol message implementing the IButtplugDeviceInfoMessage interface. /// </param> public ButtplugClientDevice(IButtplugLogManager aLogManager, ButtplugClient aOwningClient, Func <ButtplugClientDevice, ButtplugDeviceMessage, CancellationToken, Task> aSendClosure, IButtplugDeviceInfoMessage aDevInfo) : this(aLogManager, aOwningClient, aSendClosure, aDevInfo.DeviceIndex, aDevInfo.DeviceName, aDevInfo.DeviceMessages) { ButtplugUtils.ArgumentNotNull(aDevInfo, nameof(aDevInfo)); }