All pages
Powered by GitBook
1 of 1

Loading...

IEventSubscriber Delegates

MTUSDKNET API will invoke the callback function in this chapter to provide the requested data and/or a detailed response. To delegate the event, call the subscribeAll function with the name of a class that implements the IEventSubscriber Delegates interface.

OnEvent

OnEvent handles all event types. The eventType parameter defines which event is triggered.

public void OnEvent( 
    EventType eventType, 
    IData data);
Parameter
Description

eventType

Return Value: None

Example

In this example, the main window implements IEventSubscriber. The keyword this is used to pass in the name of the current class MainWindow.

Classes can be initialized by passing in the data byte array.

Example

An enumeration indicating the event triggered by the device.

data

Contains the data for the event. The payload is dependent on the event type.

Event Data Parsing

public class OnEventClass implements IEventSubscriber
{
    public void OnEvent(EventType eventType, IData data)
    {
        // Event handler
    }

}

OnEventClass eventCallBack = new OnEventClass(); 
device.subscribeAll(evenCallBack);
public partial class MainWindow implements IEventSubscriber
{
    public void OnEvent(EventType eventType, IData data)
    {
        // Event handler
    }
    
    public 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;
 
    }