#include <RealWorldTestApp.h>
Inheritance diagram for RealWorldTestApp:
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) |
handles delivered messages from overlay | |
void | handleUpperMessage (cMessage *msg) |
void | handleTimerEvent (cMessage *msg) |
processes self-messages | |
Protected Attributes | |
cMessage * | displayMsg |
void RealWorldTestApp::deliver | ( | OverlayKey & | key, | |
cMessage * | msg | |||
) | [protected, virtual] |
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.
00048 { 00049 RealWorldTestMessage* testMsg = check_and_cast<RealWorldTestMessage*>(msg); 00050 OverlayCtrlInfo* overlayCtrlInfo = 00051 check_and_cast<OverlayCtrlInfo*>(msg->removeControlInfo()); 00052 00053 if(std::string(testMsg->name()) == "CALL") { 00054 // bubble 00055 //std::string tempString = "Call for key (" + key.toString() + 00056 //") with message: \"" + testMsg->getMessage() + "\""; 00057 00058 std::string tempString = "Message received: \"" + std::string(testMsg->getMsg()) + "\""; 00059 00060 parentModule()->parentModule()->bubble(tempString.c_str()); 00061 00062 // change color 00063 parentModule()->parentModule()->displayString().setTagArg("i2", 1, "green"); 00064 00065 if(displayMsg->isScheduled()) 00066 cancelEvent(displayMsg); 00067 scheduleAt(simulation.simTime() + 2, displayMsg); 00068 00069 // send back 00070 RealWorldTestMessage* answerMsg = new RealWorldTestMessage("ANSWER"); 00071 //tempString = "Reply to: \"" + std::string(testMsg->getMessage()) + "\" from " 00072 // + overlayCtrlInfo->getThisNode().getKey().toString(); 00073 00074 tempString = "Reply to: \"" + std::string(testMsg->getMsg()) + "\" from " 00075 + overlayCtrlInfo->getThisNode().getAddress().str(); 00076 00077 answerMsg->setMsg(tempString.c_str()); 00078 callRoute(overlayCtrlInfo->getSrcNode().getKey(), answerMsg, overlayCtrlInfo->getSrcNode()); 00079 00080 delete testMsg; 00081 } else if(std::string(testMsg->name()) == "ANSWER") { 00082 if(gate("to_upperTier")->toGate()->isConnectedOutside()) 00083 send(msg, "to_upperTier"); 00084 else 00085 delete msg; 00086 } 00087 00088 delete overlayCtrlInfo; 00089 }
void RealWorldTestApp::finishApp | ( | ) | [protected, virtual] |
collects statistical data of derived app
Reimplemented from BaseApp.
00043 { 00044 cancelAndDelete(displayMsg); 00045 }
void RealWorldTestApp::handleTimerEvent | ( | cMessage * | msg | ) | [protected, virtual] |
processes self-messages
method to handle self-messages should be overwritten in derived application if needed
msg | self-message |
Reimplemented from BaseApp.
void RealWorldTestApp::handleUpperMessage | ( | cMessage * | msg | ) | [protected, virtual] |
Reimplemented from BaseApp.
00092 { 00093 RealWorldTestMessage* callMsg = check_and_cast<RealWorldTestMessage*>(msg); 00094 callMsg->setName("CALL"); 00095 callRoute(OverlayKey::sha1(const_cast<char*>(callMsg->getMsg())), callMsg); 00096 }
void RealWorldTestApp::initializeApp | ( | int | stage | ) | [protected, virtual] |
initializes derived class-attributes
stage | the init stage |
Reimplemented from BaseApp.
00035 { 00036 if (stage != MIN_STAGE_APP) 00037 return; 00038 00039 displayMsg = new cMessage("DISPLAY"); 00040 }
cMessage* RealWorldTestApp::displayMsg [protected] |