IBR-DTNSuite 0.6

daemon/src/api/ApiServer.h

Go to the documentation of this file.
00001 /*
00002  * ApiServer.h
00003  *
00004  *  Created on: 24.06.2009
00005  *      Author: morgenro
00006  */
00007 
00008 #ifndef APISERVER_H_
00009 #define APISERVER_H_
00010 
00011 #include "Component.h"
00012 #include "api/Registration.h"
00013 #include "api/ClientHandler.h"
00014 #include "core/EventReceiver.h"
00015 #include <ibrcommon/net/vinterface.h>
00016 #include <ibrcommon/net/tcpserver.h>
00017 #include <ibrcommon/thread/Mutex.h>
00018 
00019 #include <set>
00020 #include <list>
00021 
00022 namespace dtn
00023 {
00024         namespace api
00025         {
00026                 class ApiServer : public dtn::daemon::IndependentComponent, public dtn::core::EventReceiver, public ApiServerInterface
00027                 {
00028                 public:
00029                         ApiServer(const ibrcommon::File &socket);
00030                         ApiServer(const ibrcommon::vinterface &net, int port = 4550);
00031                         virtual ~ApiServer();
00032 
00036                         virtual const std::string getName() const;
00037 
00038                         void freeRegistration(Registration &reg);
00039 
00040                         void raiseEvent(const dtn::core::Event *evt);
00041 
00042                         void processIncomingBundle(const dtn::data::EID &source, dtn::data::Bundle &bundle);
00043 
00044                 protected:
00045                         bool __cancellation();
00046 
00047                         virtual void connectionUp(ClientHandler *conn);
00048                         virtual void connectionDown(ClientHandler *conn);
00049 
00050                         void componentUp();
00051                         void componentRun();
00052                         void componentDown();
00053 
00054                 private:
00055                         ibrcommon::tcpserver _srv;
00056                         std::list<Registration> _registrations;
00057                         std::list<ClientHandler*> _connections;
00058                         ibrcommon::Mutex _connection_lock;
00059                 };
00060         }
00061 }
00062 
00063 #endif /* APISERVER_H_ */