OverSim
I3Multicast.cc
Go to the documentation of this file.
1 // Copyright (C) 2006 Institut fuer Telematik, Universitaet Karlsruhe (TH)
2 //
3 // This program is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU General Public License
5 // as published by the Free Software Foundation; either version 2
6 // of the License, or (at your option) any later version.
7 //
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16 //
17 
24 #include "I3BaseApp.h"
25 
26 using namespace std;
27 
33 class I3Multicast : public I3BaseApp
34 {
35 public:
36  cMessage *sendPacketTimer;
37 
38  void initializeApp(int stage);
39  void initializeI3();
40  void deliver(I3Trigger &trigger, I3IdentifierStack &stack, cPacket *msg);
41  void handleTimerEvent(cMessage* msg);
42 };
43 
45 {
46 }
47 
49 {
50  sendPacketTimer = new cMessage("packet timer");
51  scheduleAt(simTime() + 20, sendPacketTimer);
52 
53  I3Identifier identifier("whee");
54  insertTrigger(identifier);
55 }
56 
57 
58 void I3Multicast::deliver(I3Trigger &trigger, I3IdentifierStack &stack, cPacket *msg)
59 {
60  getParentModule()->bubble("Got a message!");
61  delete msg;
62 }
63 
64 void I3Multicast::handleTimerEvent(cMessage* msg)
65 {
66  if (msg == sendPacketTimer) {
67  cPacket *cmsg = new cPacket("woot");
68  I3Identifier id("whee");
69 
70  getParentModule()->bubble("Sending message!");
71  sendPacket(id, cmsg);
72  scheduleAt(simTime() + 20, sendPacketTimer);
73  } else delete msg;
74 }
75 
77 
78