Developing Apama Applications > Developing Adapters > C/C++ Transport Plug-in Development > The C/C++ transport plug-in development specification > Communication with the codec layer
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 normalized 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 © Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or its Subsidiaries and or/its Affiliates and/or their licensors.
Use, reproduction, transfer, publication or disclosure is prohibited except as specifically provided for in your License Agreement with Software AG.