00001 // Copyright (C) 2006 Institut fuer Telematik, Universitaet Karlsruhe (TH) 00002 // 00003 // This program is free software; you can redistribute it and/or 00004 // modify it under the terms of the GNU General Public License 00005 // as published by the Free Software Foundation; either version 2 00006 // of the License, or (at your option) any later version. 00007 // 00008 // This program is distributed in the hope that it will be useful, 00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 // GNU General Public License for more details. 00012 // 00013 // You should have received a copy of the GNU General Public License 00014 // along with this program; if not, write to the Free Software 00015 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00016 // 00017 00024 #include "I3BaseApp.h" 00025 00026 using namespace std; 00027 00033 class I3Multicast : public I3BaseApp 00034 { 00035 public: 00036 cMessage *sendPacketTimer; 00037 00038 void initializeApp(int stage); 00039 void initializeI3(); 00040 void deliver(I3Trigger &trigger, I3IdentifierStack &stack, cPacket *msg); 00041 void handleTimerEvent(cMessage* msg); 00042 }; 00043 00044 void I3Multicast::initializeApp(int stage) 00045 { 00046 } 00047 00048 void I3Multicast::initializeI3() 00049 { 00050 sendPacketTimer = new cMessage("packet timer"); 00051 scheduleAt(simTime() + 20, sendPacketTimer); 00052 00053 I3Identifier identifier("whee"); 00054 insertTrigger(identifier); 00055 } 00056 00057 00058 void I3Multicast::deliver(I3Trigger &trigger, I3IdentifierStack &stack, cPacket *msg) 00059 { 00060 getParentModule()->bubble("Got a message!"); 00061 delete msg; 00062 } 00063 00064 void I3Multicast::handleTimerEvent(cMessage* msg) 00065 { 00066 if (msg == sendPacketTimer) { 00067 cPacket *cmsg = new cPacket("woot"); 00068 I3Identifier id("whee"); 00069 00070 getParentModule()->bubble("Sending message!"); 00071 sendPacket(id, cmsg); 00072 scheduleAt(simTime() + 20, sendPacketTimer); 00073 } else delete msg; 00074 } 00075 00076 Define_Module(I3Multicast); 00077 00078