Communication with the codec layer
If a transport layer plug-in is to be able to receive messages and then pass them on to the codec layer it must be able to communicate with appropriate decoding codecs. A decoding codec is one that can accept messages from the transport layer and parse them (decode them) into the normalised event format accepted by the Semantic Mapper.
When a codec is loaded into the IAF its details are passed to all transport layer plug-ins by calling their addEventDecoder function. This tells the transport layer plug-in the name of the decoding codec and provides a reference to its AP_EventDecoder structure.
The reference to AP_EventDecoder gives the transport layer plug-in access to the following functions:
sendTransportEvent
/**
* Called by the event transport to decode an event and send it on to the
* Semantic Mapper. Ownership of the message is transferred to the
* decoder when this function is called. It is assumed that the encoder
* and transport share the same definition of the content of the event, so
* that the transport can effectively interpret the event and free any
* dynamically-allocated memory.
*
* @param decoder The event decoder instance
* @param event The event to be decoded
* @param timeStamp Timestamps associated with this event
* @return Event codec error code. If this is not AP_EventCodec_OK, the
* getLastError() function of the decoder should be called to get a more
* detailed description of what went wrong.
*/
AP_EventCodecError (*sendTransportEvent)(struct AP_EventDecoder* decoder,
AP_TransportEvent event, AP_TimestampSet* timeStamp);
getLastError
/**
* getLastError
*
* Return the decoder's stored error message, if any. The message string
* is owned by the decoder so should not be modified or freed by the
* caller.
*
* @param decoder The event decoder instance
* @return The last error message generated by the decoder
*/
const AP_char8* (*getLastError)(struct AP_EventDecoder* decoder);
Assuming the reference to the AP_EventDecoder structure has been stored in a variable called decoder, the functions can be called as follows:
errorCode = decoder->functions->sendTransportEvent(decoder, event);
errorMessage = decoder->functions->getLastError(decoder);
Copyright © 2013
Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or Terracotta Inc., San Francisco, CA, USA, and/or Software AG (Canada) Inc., Cambridge, Ontario, Canada, and/or, Software AG (UK) Ltd., Derby, United Kingdom, and/or Software A.G. (Israel) Ltd., Or-Yehuda, Israel and/or their licensors.