Listener scenario: adapters process similar events
This is an example scenario in which the adapter combines watches and provides CombinedListen and CompareWatches methods.
This example describes a scenario where the adapter combines watches and provides CombinedListen and CompareWatches methods. The adapter in this example is an input to two maps and is marked as an input event for both. The following events occur at initialization:
- The Launcher starts and reads the system file (.msl) and calls the Resource Manager, passing the details of two watches for the adapter.
- The Resource Manager calls the ValidateProperties method of the adapter with Watch 1 data.
- The Resource Manager calls the ValidateProperties method of the adapter with Watch 2 data.
- The Resource Manager calls the CompareWatches method with adapter objects from the above calls. Because the adapter will handle the events itself, it returns information indicating that the watches are the same (MPI_CMP_EQUAL).
- The Resource Manager creates a thread (T1) and calls the Connect method with the adapter object (from Step 2). Resource Manager has an arbitrary choice. Because the adapter has indicated that the watches are equivalent, it should not matter which adapter object is used to determine the connection parameters.
- (T1): The Resource Manager calls the OnNotify (MPIN_LISTEN_START) method and then the CombinedListen method with both of the adapter objects from Steps 2 and 3 in an hAdapterCollection.
- The Resource Manager notifies the Launcher that the
listener started successfully.
Now an event occurs.
- (T1): The CombinedListen method identifies whether the adapter objects have been triggered and adds messages to the collection objects of the adapters.
- (T1): The Resource Manager notifies the Launcher passing the appropriate adapter object.
- (T1): The Resource Manager calls the CombinedListen method again.
- The map runs and the Resource Manager is called for input.