This interface invokes a callback function to receive data and/or a detailed response. To register for the event(s), call the subscribeAll() function with the name of a class that implements the IEventSubscriber Delegate interface.
This is the handler for multiple event types.
public void OnEvent(
EventType eventType,
IData data);Parameter
Description
eventType
An enumeration for EventType. This indicates the event triggered by the device.
data
Contains the data for the event. The payload is dependent on the event type.
Return Value: None
Event implementation
The OnEvent method must be included and parameterized correctly as shown below to conform to the interface.
In this example, a separate class implements IEventSubscriber.
In this example, the main window implements IEventSubscriber. The keyword “this” is used to pass in the name of the current class MainWindow.
Event Data Parsing
Classes can be initialized by passing in the data byte array. Example:
class OnEventClass : IEventSubscriber
{
public void OnEvent(EventType eventType, IData data)
{
// Event handler
}
}
OnEventClass eventCallBack = new OnEventClass();
device.subscribeAll(eventCallBack);public partial class MainWindow : Window, IEventSubscriber
{
public void OnEvent(EventType eventType, IData data)
{
// Event handler
}
private void connectDevice()
{
device.subscribeAll(this);
}
}
public void OnEvent(EventType eventType, IData data)
{
// Barcode data
BarCodeData barcodeData =
BarCodeDataBuilder.GetBarCodeData(DeviceType.MMS, data.ByteArray);
// Input request
InputRequest ir = new InputRequest(data.ByteArray);
// NFC data
NFCData nfcData = NFCDataBuilder.GetNFCData(DeviceType.MMS, data.ByteArray);
// Enhanced input request
EnhancedInputRequest eir = new
EnhancedInputRequest(data.ByteArray);
List<DirectoryEntry> deList = eir.EnhancedSelectionList;
}