CombinedListen method

The CombinedListen method is generally the same as the Listen method. The difference is that the CombinedListen method listens for multiple watches.

MPIRC CombinedListen (HMPIADAPTCOLL  
hAdapterColl,HCONNECTION  hConnection)

Inputs

hAdapterColl
Adapter collection handle
hConnection
Connection handle

Outputs

None

Returns

MPIRC_EVENT
Event occurred
MPIRC_NO_EVENT
No event occurred
MPIRC_BAD_CONNECTION
Connection failed other success status
This method receives an adapter collection object, which is a container for adapter objects. Notice that there is only one connection object because all watches are accessing the same resource. To determine the number of adapter objects in the collection, the following method should be invoked:
mpiAdaptCollGetCount (hAdapterColl, &iCount);
Upon detection of an event, CombinedListen must determine the watches for which the event applies. For example, the combined listener is looking for the following files:
  • Watch #1: A*.txt
  • Watch #2: ABC*.txt

If a file is discovered with the name AXYZ.txt, the event is applicable to the first watch only. However, if a file with name of ABCXYZ.txt is discovered, this would be applicable to both Watch 1 and 2.

Having determined the watches to which the event applies, a message should be added to the MPIP_ADAPTER_MSG_COLLECTION property for each corresponding adapter object (in the same way as described in the Listen method). Note that in the above example, the value of the wildcard would differ in the two message collections.

Between successive calls to CombinedListen, a watch might be added or removed. This means that it is necessary for the adapter to check the number of adapter objects in the collection on each invocation. If the number of adapter objects changes between invocations, the adapter might need to do additional processing. For example, to adjust filtering of messages accordingly.