Implemented pipe events.

This commit is contained in:
Klaus Reimer 2011-02-05 16:36:23 +01:00 committed by k
parent 33a215b319
commit ea6b8cc5b4
2 changed files with 23 additions and 0 deletions

View File

@ -181,6 +181,7 @@ final class PipeQueueProcessor extends Thread
irp.setUsbException(e); irp.setUsbException(e);
} }
irp.complete(); irp.complete();
this.pipe.sendEvent(irp);
} }

View File

@ -17,6 +17,8 @@ import javax.usb.UsbNotActiveException;
import javax.usb.UsbNotClaimedException; import javax.usb.UsbNotClaimedException;
import javax.usb.UsbNotOpenException; import javax.usb.UsbNotOpenException;
import javax.usb.UsbPipe; import javax.usb.UsbPipe;
import javax.usb.event.UsbPipeDataEvent;
import javax.usb.event.UsbPipeErrorEvent;
import javax.usb.event.UsbPipeListener; import javax.usb.event.UsbPipeListener;
import javax.usb.util.DefaultUsbControlIrp; import javax.usb.util.DefaultUsbControlIrp;
import javax.usb.util.DefaultUsbIrp; import javax.usb.util.DefaultUsbIrp;
@ -384,6 +386,26 @@ final class UsbPipeImpl implements UsbPipe
} }
/**
* Sends event to all event listeners.
*
* @param irp
* Then request package
*/
void sendEvent(final UsbIrp irp)
{
if (irp.isUsbException())
{
this.listeners.errorEventOccurred(new UsbPipeErrorEvent(this, irp));
}
else
{
this.listeners.dataEventOccurred(new UsbPipeDataEvent(this, irp));
}
}
/** /**
* Returns the request packet queue. * Returns the request packet queue.
* *