#include <RealWorldTestApp.h>
Protected Member Functions | |
void | initializeApp (int stage) |
initializes derived class-attributes | |
void | finishApp () |
collects statistical data of derived app | |
void | deliver (OverlayKey &key, cMessage *msg) |
Common API function: handles delivered messages from overlay. | |
void | handleUpperMessage (cMessage *msg) |
handleUpperMessage gets called of handleMessage(cMessage* msg) if msg arrivedOn from_upperTier (currently msg gets deleted in this function) | |
void | handleTimerEvent (cMessage *msg) |
Protected Attributes | |
cMessage * | displayMsg |
Definition at line 37 of file RealWorldTestApp.h.
void RealWorldTestApp::deliver | ( | OverlayKey & | key, | |
cMessage * | msg | |||
) | [protected, virtual] |
Common API function: handles delivered messages from overlay.
method to handle decapsulated KBRdeliver messages from overlay module, should be overwritten in derived application
key | destination key | |
msg | delivered message |
Reimplemented from BaseApp.
Definition at line 48 of file RealWorldTestApp.cc.
{ RealWorldTestMessage* testMsg = check_and_cast<RealWorldTestMessage*>(msg); OverlayCtrlInfo* overlayCtrlInfo = check_and_cast<OverlayCtrlInfo*>(msg->removeControlInfo()); if(std::string(testMsg->getName()) == "CALL") { // bubble //std::string tempString = "Call for key (" + key.toString() + //") with message: \"" + testMsg->getMessage() + "\""; std::string tempString = "Message received: \"" + std::string(testMsg->getMsg()) + "\""; getParentModule()->getParentModule()->bubble(tempString.c_str()); // change color getParentModule()->getParentModule()->getDisplayString().setTagArg("i2", 1, "green"); if(displayMsg->isScheduled()) cancelEvent(displayMsg); scheduleAt(simTime() + 2, displayMsg); // send back RealWorldTestMessage* answerMsg = new RealWorldTestMessage("ANSWER"); //tempString = "Reply to: \"" + std::string(testMsg->getMessage()) + "\" from " // + overlayCtrlInfo->getThisNode().getKey().toString(); tempString = "Reply to: \"" + std::string(testMsg->getMsg()) + "\" from " + overlay->getThisNode().getIp().str(); answerMsg->setMsg(tempString.c_str()); callRoute(overlayCtrlInfo->getSrcNode().getKey(), answerMsg, overlayCtrlInfo->getSrcNode()); delete testMsg; } else if(std::string(testMsg->getName()) == "ANSWER") { if(gate("to_upperTier")->getNextGate()->isConnectedOutside()) send(msg, "to_upperTier"); else delete msg; } delete overlayCtrlInfo; }
void RealWorldTestApp::finishApp | ( | ) | [protected, virtual] |
collects statistical data of derived app
Reimplemented from BaseApp.
Definition at line 43 of file RealWorldTestApp.cc.
{ cancelAndDelete(displayMsg); }
void RealWorldTestApp::handleTimerEvent | ( | cMessage * | msg | ) | [protected] |
Definition at line 99 of file RealWorldTestApp.cc.
{ getParentModule()->getParentModule()->getDisplayString().setTagArg("i2", 1, ""); }
void RealWorldTestApp::handleUpperMessage | ( | cMessage * | msg | ) | [protected, virtual] |
handleUpperMessage gets called of handleMessage(cMessage* msg) if msg arrivedOn from_upperTier (currently msg gets deleted in this function)
msg | the message to handle |
Reimplemented from BaseApp.
Definition at line 92 of file RealWorldTestApp.cc.
{ RealWorldTestMessage* callMsg = check_and_cast<RealWorldTestMessage*>(msg); callMsg->setName("CALL"); callRoute(OverlayKey::sha1(const_cast<char*>(callMsg->getMsg())), callMsg); }
void RealWorldTestApp::initializeApp | ( | int | stage | ) | [protected, virtual] |
initializes derived class-attributes
stage | the init stage |
Reimplemented from BaseApp.
Definition at line 35 of file RealWorldTestApp.cc.
{ if (stage != MIN_STAGE_APP) return; displayMsg = new cMessage("DISPLAY"); }
cMessage* RealWorldTestApp::displayMsg [protected] |
Definition at line 50 of file RealWorldTestApp.h.
Referenced by deliver(), finishApp(), and initializeApp().