#include <ScribeTest.h>
Public Member Functions | |
| ScribeTest () | |
| ~ScribeTest () | |
Protected Member Functions | |
| void | handleMessage (cMessage *msg) |
| void | joinGroup (int i) |
| void | leaveGroup (int i) |
| void | sendDataToGroup (int i) |
| void | handleMCast (ALMMulticastMessage *mcast) |
Protected Attributes | |
| cMessage * | timer |
| int | groupNum |
Definition at line 31 of file ScribeTest.h.
| ScribeTest::ScribeTest | ( | ) | [inline] |
| ScribeTest::~ScribeTest | ( | ) | [inline] |
| void ScribeTest::handleMCast | ( | ALMMulticastMessage * | mcast | ) | [protected] |
Definition at line 74 of file ScribeTest.cc.
Referenced by handleMessage().
00075 { 00076 getParentModule()->getParentModule()->bubble("Received message!"); 00077 EV << "[ScribeTest::handleMCast()]\n" 00078 << " App received data message for group: " << mcast->getGroupId() 00079 << endl; 00080 delete mcast; 00081 }
| void ScribeTest::handleMessage | ( | cMessage * | msg | ) | [protected] |
Definition at line 28 of file ScribeTest.cc.
00029 { 00030 if( msg == timer ) { 00031 double random = uniform( 0, 1 ); 00032 if( random < 0.1 || groupNum < 1 ) { 00033 joinGroup( ++groupNum ); 00034 } else if( random < 0.2 ) { 00035 leaveGroup( groupNum-- ); 00036 } else { 00037 sendDataToGroup( intuniform( 1, groupNum )); 00038 } 00039 scheduleAt( simTime() + 10, timer ); 00040 00041 } else if( ALMMulticastMessage* mcast = dynamic_cast<ALMMulticastMessage*>(msg) ){ 00042 handleMCast( mcast ); 00043 } else if( CompReadyMessage* readyMsg = dynamic_cast<CompReadyMessage*>(msg) ){ 00044 if( readyMsg->getReady() ) { 00045 groupNum = 0; 00046 cancelEvent( timer ); 00047 scheduleAt( simTime() + 1, timer ); 00048 } 00049 delete msg; 00050 } 00051 }
| void ScribeTest::joinGroup | ( | int | i | ) | [protected] |
Definition at line 53 of file ScribeTest.cc.
Referenced by handleMessage().
00054 { 00055 ALMSubscribeMessage* msg = new ALMSubscribeMessage; 00056 msg->setGroupId(OverlayKey(i)); 00057 send(msg, "to_lowerTier"); 00058 }
| void ScribeTest::leaveGroup | ( | int | i | ) | [protected] |
Definition at line 60 of file ScribeTest.cc.
Referenced by handleMessage().
00061 { 00062 ALMLeaveMessage* msg = new ALMLeaveMessage; 00063 msg->setGroupId(OverlayKey(i)); 00064 send(msg, "to_lowerTier"); 00065 }
| void ScribeTest::sendDataToGroup | ( | int | i | ) | [protected] |
Definition at line 67 of file ScribeTest.cc.
Referenced by handleMessage().
00068 { 00069 ALMMulticastMessage* msg = new ALMMulticastMessage("FOO!"); 00070 msg->setGroupId(OverlayKey(i)); 00071 send(msg, "to_lowerTier"); 00072 }
int ScribeTest::groupNum [protected] |
cMessage* ScribeTest::timer [protected] |
Definition at line 41 of file ScribeTest.h.
Referenced by handleMessage(), ScribeTest(), and ~ScribeTest().
1.5.8