Example #1
0
/**
 * @brief    Send one of multiple replys to a pending message.
 */
int TMLCoreListener::SendAnsReply(VortexChannel* channel, int iMsgID, char* data, int iDataLength)
{
  int iRet = TML_SUCCESS;

  m_log->log (TML_LOG_VORTEX_CMD, "TMLCoreListener", "SendAnsReply", "Vortex CMD", "vortex_channel_send_ans_rpy");
  if (axl_false == vortex_channel_send_ans_rpy (channel, data, iDataLength, iMsgID)){
    iRet = TML_ERR_LISTENER_COMMUNICATION;
    m_log->log (TML_LOG_MULTI_SYNC_CMDS, "TMLCoreListener", "SendAnsReply", "Communication error using", "vortex_channel_send_ans_rpy");
  }
  return iRet;
}
void frame_received (VortexChannel    * channel,
                     VortexConnection * connection,
                     VortexFrame      * frame,
                     axlPointer           user_data)
{
    VortexAsyncQueue * queue;
    int                iterator = 0;


    printf ("A frame received on channl: %d\n",     vortex_channel_get_number (channel));
    printf ("Data received: '%s'\n",                (char*) vortex_frame_get_payload (frame));

    if (vortex_frame_get_type (frame) == VORTEX_FRAME_TYPE_MSG) {
        /* send back a series of replies */
        queue = vortex_async_queue_new ();

        while (iterator < 100) {
            /* wait during 50ms */
            vortex_async_queue_timedpop (queue, 50000);

            /* send a reply */
            vortex_channel_send_ans_rpy (channel, "This is a reply to the message", 30, vortex_frame_get_msgno (frame));

            /* next message */
            iterator++;
        }

        /* send NUL */
        vortex_channel_finalize_ans_rpy (channel, vortex_frame_get_msgno (frame));

    }

    printf ("VORTEX_LISTENER: end task (pid: %d)\n", getpid ());


    return;
}