#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.
00049 { 00050 RealWorldTestMessage* testMsg = check_and_cast<RealWorldTestMessage*>(msg); 00051 OverlayCtrlInfo* overlayCtrlInfo = 00052 check_and_cast<OverlayCtrlInfo*>(msg->removeControlInfo()); 00053 00054 if(std::string(testMsg->getName()) == "CALL") { 00055 // bubble 00056 //std::string tempString = "Call for key (" + key.toString() + 00057 //") with message: \"" + testMsg->getMessage() + "\""; 00058 00059 std::string tempString = "Message received: \"" + std::string(testMsg->getMsg()) + "\""; 00060 00061 getParentModule()->getParentModule()->bubble(tempString.c_str()); 00062 00063 // change color 00064 getParentModule()->getParentModule()->getDisplayString().setTagArg("i2", 1, "green"); 00065 00066 if(displayMsg->isScheduled()) 00067 cancelEvent(displayMsg); 00068 scheduleAt(simTime() + 2, displayMsg); 00069 00070 // send back 00071 RealWorldTestMessage* answerMsg = new RealWorldTestMessage("ANSWER"); 00072 //tempString = "Reply to: \"" + std::string(testMsg->getMessage()) + "\" from " 00073 // + overlayCtrlInfo->getThisNode().getKey().toString(); 00074 00075 tempString = "Reply to: \"" + std::string(testMsg->getMsg()) + "\" from " 00076 + overlay->getThisNode().getAddress().str(); 00077 00078 answerMsg->setMsg(tempString.c_str()); 00079 callRoute(overlayCtrlInfo->getSrcNode().getKey(), answerMsg, overlayCtrlInfo->getSrcNode()); 00080 00081 delete testMsg; 00082 } else if(std::string(testMsg->getName()) == "ANSWER") { 00083 if(gate("to_upperTier")->getNextGate()->isConnectedOutside()) 00084 send(msg, "to_upperTier"); 00085 else 00086 delete msg; 00087 } 00088 00089 delete overlayCtrlInfo; 00090 }
void RealWorldTestApp::finishApp | ( | ) | [protected, virtual] |
collects statistical data of derived app
Reimplemented from BaseApp.
Definition at line 43 of file RealWorldTestApp.cc.
00044 { 00045 cancelAndDelete(displayMsg); 00046 }
void RealWorldTestApp::handleTimerEvent | ( | cMessage * | msg | ) | [protected, virtual] |
Reimplemented from BaseRpc.
Definition at line 99 of file RealWorldTestApp.cc.
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.
00093 { 00094 RealWorldTestMessage* callMsg = check_and_cast<RealWorldTestMessage*>(msg); 00095 callMsg->setName("CALL"); 00096 callRoute(OverlayKey::sha1(const_cast<char*>(callMsg->getMsg())), callMsg); 00097 }
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.
00036 { 00037 if (stage != MIN_STAGE_APP) 00038 return; 00039 00040 displayMsg = new cMessage("DISPLAY"); 00041 }
cMessage* RealWorldTestApp::displayMsg [protected] |
Definition at line 50 of file RealWorldTestApp.h.
Referenced by deliver(), finishApp(), and initializeApp().