void frame_received (VortexChannel * channel, VortexConnection * connection, VortexFrame * frame, axlPointer user_data) { int iterator = 10; printf ("A frame received on channl: %d\n", vortex_channel_get_number (channel)); printf ("Data received: '%s'\n", (char*) vortex_frame_get_payload (frame)); /* reply the peer client with the same content 10 times */ while (iterator >= 0) { printf ("Sending the reply..\n"); if (! vortex_channel_send_ans_rpyv (channel, vortex_frame_get_msgno (frame), "Received Ok(%d): %s", iterator, vortex_frame_get_payload (frame))) { fprintf (stderr, "There was an error while sending the reply message"); } printf ("Reply: %d sent..\n", iterator); iterator--; } /* send the last reply. */ if (!vortex_channel_finalize_ans_rpy (channel, vortex_frame_get_msgno (frame))) { fprintf (stderr, "There was an error while sending the NUL reply message"); } printf ("VORTEX_LISTENER: end task (pid: %d)\n", getpid ()); return; }
/** * @brief Send the end of multiple replys to a pending message. */ int TMLCoreListener::SendFinalAnsReply(VortexChannel* channel, int iMsgID) { int iRet = TML_SUCCESS; // DEBUG_QVENT_QUEUE */ m_log->log ("TMLCoreListener", "SendFinalAnsReply", "Vortex CMD vortex_channel_finalize_ans_rpy No ", iMsgID); m_log->log (TML_LOG_VORTEX_CMD, "TMLCoreListener", "SendFinalAnsReply", "Vortex CMD", "vortex_channel_finalize_ans_rpy"); if (m_log->getLoggingValue() & TML_LOG_MULTI_SYNC_CMDS){ m_log->log (TML_LOG_MULTI_SYNC_CMDS, "TMLCoreListener", "SendFinalAnsReply", "MessageCounter", m_iMultiSyncMessageCounter); ++m_iMultiSyncMessageCounter; } if (axl_false == vortex_channel_finalize_ans_rpy (channel, iMsgID)){ iRet = TML_ERR_LISTENER_COMMUNICATION; m_log->log (TML_LOG_MULTI_SYNC_CMDS, "TMLCoreListener", "SendAnsReply", "Communication error using", "vortex_channel_finalize_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; }