/// <summary>
        /// Sends RETRACT_DEVICE request to the client to stop redirecting the USB device.
        /// </summary>
        /// <param name="device">The context of the device which is being operated.</param>
        /// <param name="reason">The reason to stop redirecting the USB device.</param>
        public void RetractDevice(EusbDeviceContext device, USB_RETRACT_REASON reason)
        {
            Site.Log.Add(LogEntryKind.Debug, "Sending RETRACT_DEVICE. Device: {0}", device);

            EusbRetractDevicePdu requestPdu = new EusbRetractDevicePdu(device.UsbDeviceInterfaceId);

            requestPdu.Reason = reason;
            SendPdu(requestPdu, device.VirtualChannel);

            bool channelClosed = IsChannelClosed(device.VirtualChannel);

            Site.Assert.IsTrue(channelClosed, "Expect the channel {0} to be closed.", device.VirtualChannel.ChannelId);
        }
 /// <summary>
 /// Decode this PDU from the PduMarshaler.
 /// </summary>
 /// <param name="marshaler">This is used to decode the fields of this PDU.</param>
 public override bool Decode(PduMarshaler marshaler)
 {
     try
     {
         base.Decode(marshaler);
         Reason = (USB_RETRACT_REASON)marshaler.ReadUInt32();
     }
     catch (Exception)
     {
         return false;
     }
     return true;
 }
        /// <summary>
        /// Sends RETRACT_DEVICE request to the client to stop redirecting the USB device.
        /// </summary>
        /// <param name="device">The context of the device which is being operated.</param>
        /// <param name="reason">The reason to stop redirecting the USB device.</param>
        public void RetractDevice(EusbDeviceContext device, USB_RETRACT_REASON reason)
        {
            Site.Log.Add(LogEntryKind.Debug, "Sending RETRACT_DEVICE. Device: {0}", device);

            EusbRetractDevicePdu requestPdu = new EusbRetractDevicePdu(device.UsbDeviceInterfaceId);
            requestPdu.Reason = reason;
            SendPdu(requestPdu, device.VirtualChannel);

            bool channelClosed = IsChannelClosed(device.VirtualChannel);
            Site.Assert.IsTrue(channelClosed, "Expect the channel {0} to be closed.", device.VirtualChannel.ChannelId);
        }