IBR-DTNSuite
0.8
|
00001 /* 00002 * ConnectionEvent.cpp 00003 * 00004 * Created on: 16.02.2010 00005 * Author: morgenro 00006 */ 00007 00008 #include "net/ConnectionEvent.h" 00009 00010 namespace dtn 00011 { 00012 namespace net 00013 { 00014 ConnectionEvent::ConnectionEvent(State s, const dtn::core::Node &n) 00015 : state(s), peer(n.getEID()), node(n) 00016 { 00017 00018 } 00019 00020 ConnectionEvent::~ConnectionEvent() 00021 { 00022 00023 } 00024 00025 void ConnectionEvent::raise(State s, const dtn::core::Node &n) 00026 { 00027 // raise the new event 00028 dtn::core::Event::raiseEvent( new ConnectionEvent(s, n) ); 00029 } 00030 00031 const string ConnectionEvent::getName() const 00032 { 00033 return ConnectionEvent::className; 00034 } 00035 00036 00037 std::string ConnectionEvent::toString() const 00038 { 00039 switch (state) 00040 { 00041 case CONNECTION_UP: 00042 return className + ": connection up " + peer.getString(); 00043 case CONNECTION_DOWN: 00044 return className + ": connection down " + peer.getString(); 00045 case CONNECTION_TIMEOUT: 00046 return className + ": connection timeout " + peer.getString(); 00047 case CONNECTION_SETUP: 00048 return className + ": connection setup " + peer.getString(); 00049 } 00050 00051 } 00052 00053 const string ConnectionEvent::className = "ConnectionEvent"; 00054 } 00055 }