WIP, adding remote test client/server

This commit is contained in:
emeric
2014-04-14 22:56:20 +02:00
parent 298f6fb885
commit 9409fadc63
22 changed files with 438 additions and 46 deletions
Binary file not shown.
+1 -1
View File
@@ -1,7 +1,7 @@
#include "DatabaseRefreshService.hpp"
DatabaseRefreshService::DatabaseRefreshService(const boost::filesystem::path& p)
DatabaseRefreshService::DatabaseRefreshService(boost::asio::io_service& ioService, const boost::filesystem::path& p)
: _metadataParser(),
_database( p, _metadataParser)
{
+3 -1
View File
@@ -1,6 +1,8 @@
#ifndef DB_REFRESH_SERVICE_HPP
#define DB_REFRESH_SERVICE_HPP
#include <boost/asio/io_service.hpp>
#include "metadata/AvFormat.hpp"
#include "database/Database.hpp"
@@ -10,7 +12,7 @@ class DatabaseRefreshService : public Service
{
public:
DatabaseRefreshService(const boost::filesystem::path& p);
DatabaseRefreshService(boost::asio::io_service& ioService, const boost::filesystem::path& p);
void start(void);
void stop(void);
+2 -2
View File
@@ -1,8 +1,8 @@
#include "RemoteServerService.hpp"
RemoteServerService::RemoteServerService(const Remote::Server::Server::endpoint_type& endpoint, boost::filesystem::path dbPath)
: _server(endpoint, dbPath)
RemoteServerService::RemoteServerService(boost::asio::io_service& ioService, const Remote::Server::Server::endpoint_type& endpoint, boost::filesystem::path dbPath)
: _server(ioService, endpoint, dbPath)
{
}
+1 -1
View File
@@ -11,7 +11,7 @@ class RemoteServerService : public Service
{
public:
RemoteServerService(const Remote::Server::Server::endpoint_type& endpoint, boost::filesystem::path dbPath);
RemoteServerService(boost::asio::io_service& ioService, const Remote::Server::Server::endpoint_type& endpoint, boost::filesystem::path dbPath);
void start(void);
void stop(void);
+3
View File
@@ -24,6 +24,7 @@ ServiceManager::run()
asyncWaitSignals();
std::cout << "ServiceManager::run Waiting for events..." << std::endl;
// Wait for events
_ioService.run();
@@ -42,8 +43,10 @@ ServiceManager::asyncWaitSignals(void)
void
ServiceManager::startService(Service::pointer service)
{
std::cout << "ServiceManager::startService" << std::endl;
_services.insert(service);
service->start();
std::cout << "ServiceManager::startService done" << std::endl;
}
void
+3
View File
@@ -19,6 +19,9 @@ class ServiceManager
// Return in case of failure/stop by user
void run();
boost::asio::io_service& getIoService() {return _ioService;}
const boost::asio::io_service& getIoService() const {return _ioService;}
private:
void restartServices(void);
+7 -2
View File
@@ -24,14 +24,19 @@ int main(int argc, char* argv[])
// TODO Retreive the database path in some config file
const boost::filesystem::path dbPath("test.db");
Remote::Server::Server::endpoint_type remoteListenEndpoint( boost::asio::ip::address::from_string("0.0.0.0"), 5080);
// lib init
Av::AvInit();
Transcode::AvConvTranscoder::init();
serviceManager.startService( std::make_shared<DatabaseRefreshService>( dbPath) );
std::cout << "Starting services..." << std::endl;
serviceManager.startService( std::make_shared<DatabaseRefreshService>( serviceManager.getIoService(), dbPath) );
serviceManager.startService( std::make_shared<RemoteServerService>( serviceManager.getIoService(), remoteListenEndpoint, dbPath) );
serviceManager.startService( std::make_shared<UserInterfaceService>(argc, argv, dbPath) );
serviceManager.startService( std::make_shared<RemoteServerService>( Remote::Server::Server::endpoint_type(), dbPath) );
std::cout << "Running..." << std::endl;
serviceManager.run();