//------------------------------------------------------------------------ tresult Plug::sendTextMessage (const char16* text) { IMessage* message = allocateMessage (); if (!message) return kResultFalse; FReleaser msgReleaser (message); message->setMessageID ("TextMessage"); message->getAttributes ()->setString ("Text", text); return sendMessage (message); }
//------------------------------------------------------------------------ tresult ComponentBase::sendTextMessage (const char8* text) { IMessage* message = allocateMessage (); if (!message) return kResultFalse; FReleaser msgReleaser (message); message->setMessageID ("TextMessage"); message->getAttributes ()->setString ("Text", STR (text)); return sendMessage (message); }
void RPG_Net_Module_ProtocolHandler::handleTimeout (const void* arg_in) { RPG_TRACE (ACE_TEXT ("RPG_Net_Module_ProtocolHandler::handleTimeout")); int result = -1; ACE_UNUSED_ARG (arg_in); // ACE_DEBUG ((LM_DEBUG, // ACE_TEXT ("timer (ID: %d) expired...sending ping\n"), // timerID_)); // step0: create ping structure --> get a message buffer Net_Message* message_p = allocateMessage (sizeof (Net_Remote_Comm::PingMessage)); if (!message_p) { ACE_DEBUG ((LM_ERROR, ACE_TEXT ("failed to allocate ping message(%u), returning\n"), sizeof (Net_Remote_Comm::PingMessage))); return; } // end IF // step1: initialize ping data // *TODO*: clean this up and handle endianness consistently ! Net_Remote_Comm::PingMessage* ping_struct_p = reinterpret_cast<Net_Remote_Comm::PingMessage*> (message_p->wr_ptr ()); ACE_OS::memset (ping_struct_p, 0, sizeof (Net_Remote_Comm::PingMessage)); ping_struct_p->messageHeader.messageLength = (sizeof (Net_Remote_Comm::PingMessage) - sizeof (unsigned int)); ping_struct_p->messageHeader.messageType = Net_Remote_Comm::NET_PING; ping_struct_p->counter = counter_++; message_p->wr_ptr (sizeof (Net_Remote_Comm::PingMessage)); // step2: send it upstream result = inherited::reply (message_p, NULL); if (result == -1) { ACE_DEBUG ((LM_ERROR, ACE_TEXT ("failed to ACE_Task::reply(): \"%m\", returning\n"))); // clean up message_p->release (); return; } // end IF }
void RPG_Net_Module_ProtocolHandler::handleDataMessage (Net_Message*& message_inout, bool& passMessageDownstream_out) { RPG_TRACE (ACE_TEXT ("RPG_Net_Module_ProtocolHandler::handleDataMessage")); int result = -1; // don't care (implies yes per default, if part of a stream) ACE_UNUSED_ARG (passMessageDownstream_out); // retrieve type of message and other details... Net_Remote_Comm::MessageHeader* message_header_p = reinterpret_cast<Net_Remote_Comm::MessageHeader*> (message_inout->rd_ptr ()); switch (message_header_p->messageType) { case Net_Remote_Comm::NET_PING: { // auto-answer ? if (automaticPong_) { // --> reply with a "PONG" // step0: create reply structure // --> get a message buffer Net_Message* message_p = allocateMessage (sizeof (Net_Remote_Comm::PongMessage)); if (!message_p) { ACE_DEBUG ((LM_ERROR, ACE_TEXT ("failed to allocate reply message(%u), aborting\n"), sizeof (Net_Remote_Comm::PongMessage))); return; } // end IF // step1: initialize reply Net_Remote_Comm::PongMessage* reply_struct_p = reinterpret_cast<Net_Remote_Comm::PongMessage*>(message_p->wr_ptr ()); ACE_OS::memset (reply_struct_p, 0, sizeof (Net_Remote_Comm::PongMessage)); reply_struct_p->messageHeader.messageLength = sizeof (Net_Remote_Comm::PongMessage) - sizeof (unsigned int); reply_struct_p->messageHeader.messageType = Net_Remote_Comm::NET_PONG; message_p->wr_ptr (sizeof (Net_Remote_Comm::PongMessage)); // step2: send it upstream result = inherited::reply (message_p, NULL); if (result == -1) { ACE_DEBUG ((LM_ERROR, ACE_TEXT ("failed to ACE_Task::reply(): \"%m\", aborting\n"))); // clean up message_p->release (); return; } // end IF } // end IF break; } case Net_Remote_Comm::NET_PONG: { //ACE_DEBUG ((LM_DEBUG, // ACE_TEXT ("received PONG (connection ID: %u)...\n"), // mySessionID)); if (printPongDot_) std::clog << '.'; break; } default: { ACE_DEBUG ((LM_ERROR, ACE_TEXT ("[%u]: unknown message type: \"%s\": protocol error, continuing\n"), message_inout->getID (), ACE_TEXT (Net_Message::CommandType2String (message_header_p->messageType).c_str ()))); break; } } // end SWITCH }