diff options
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/HTTPClientReceiver.cpp | 19 | ||||
-rw-r--r-- | src/client/HTTPClientReceiver.hpp | 5 | ||||
-rw-r--r-- | src/client/client.cpp | 64 | ||||
-rw-r--r-- | src/client/client.hpp | 45 |
4 files changed, 44 insertions, 89 deletions
diff --git a/src/client/HTTPClientReceiver.cpp b/src/client/HTTPClientReceiver.cpp index b8229998..879d648a 100644 --- a/src/client/HTTPClientReceiver.cpp +++ b/src/client/HTTPClientReceiver.cpp @@ -127,7 +127,7 @@ HTTPClientReceiver::close_session() void HTTPClientReceiver::update(const std::string& str) { - cout << _parser->parse_update(_world, _target.get(), str, _url); + cout << _world->parser->parse_update(_world, _target.get(), str, _url); } void @@ -185,7 +185,7 @@ HTTPClientReceiver::message_callback(SoupSession* session, SoupMessage* msg, voi } else { Glib::Mutex::Lock lock(me->_mutex); me->_target->response_ok(0); - me->_parser->parse_string(me->_world, me->_target.get(), + me->_world->parser->parse_string(me->_world, me->_target.get(), Glib::ustring(msg->response_body->data), me->_url); } @@ -195,7 +195,7 @@ HTTPClientReceiver::message_callback(SoupSession* session, SoupMessage* msg, voi } else { Glib::Mutex::Lock lock(me->_mutex); me->_target->response_ok(0); - me->_parser->parse_string(me->_world, me->_target.get(), + me->_world->parser->parse_string(me->_world, me->_target.get(), Glib::ustring(msg->response_body->data), Glib::ustring("/patch/")); } @@ -224,16 +224,9 @@ void HTTPClientReceiver::start(bool dump) { Glib::Mutex::Lock lock(_world->rdf_world->mutex()); - if (!_parser) { - if (!_world->serialisation_module) - _world->serialisation_module = Ingen::Shared::load_module("ingen_serialisation"); - - if (_world->serialisation_module) { - Parser* (*new_parser)() = NULL; - if (_world->serialisation_module->get_symbol("new_parser", (void*&)new_parser)) - _parser = SharedPtr<Parser>(new_parser()); - } - } + + if (!_world->parser) + _world->load("ingen_serialisation"); SoupMessage* msg = soup_message_new("GET", (_url + "/stream").c_str()); soup_session_queue_message(client_session, msg, message_callback, this); diff --git a/src/client/HTTPClientReceiver.hpp b/src/client/HTTPClientReceiver.hpp index 7cb42948..4916ddea 100644 --- a/src/client/HTTPClientReceiver.hpp +++ b/src/client/HTTPClientReceiver.hpp @@ -71,9 +71,8 @@ private: Glib::Mutex _mutex; SharedPtr<Shared::ClientInterface> _target; - Shared::World* _world; - const std::string _url; - SharedPtr<Serialisation::Parser> _parser; + Shared::World* _world; + const std::string _url; }; diff --git a/src/client/client.cpp b/src/client/client.cpp index 53d7810f..9512ba44 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -16,9 +16,9 @@ */ #include "ingen-config.h" - -#include <iostream> -#include "client.hpp" +#include "raul/SharedPtr.hpp" +#include "module/Module.hpp" +#include "module/World.hpp" #ifdef HAVE_LIBLO #include "OSCEngineSender.hpp" #endif @@ -26,39 +26,47 @@ #include "HTTPEngineSender.hpp" #endif +using namespace Ingen; -using namespace std; - -namespace Ingen { -namespace Client { - - +#ifdef HAVE_LIBLO SharedPtr<Ingen::Shared::EngineInterface> -new_remote_interface(Ingen::Shared::World* world, const std::string& url) +new_osc_interface(Ingen::Shared::World* world, const std::string& url) { - const string scheme = url.substr(0, url.find(":")); - -#ifdef HAVE_LIBLO - if (scheme == "osc.udp" || scheme == "osc.tcp") { - OSCEngineSender* oes = OSCEngineSender::create(url); - oes->attach(rand(), true); - return SharedPtr<Shared::EngineInterface>(oes); - } + Client::OSCEngineSender* oes = Client::OSCEngineSender::create(url); + oes->attach(rand(), true); + return SharedPtr<Shared::EngineInterface>(oes); +} #endif #ifdef HAVE_SOUP - if (scheme == "http") { - HTTPEngineSender* hes = new HTTPEngineSender(world, url); - hes->attach(rand(), true); - return SharedPtr<Shared::EngineInterface>(hes); - } +SharedPtr<Ingen::Shared::EngineInterface> +new_http_interface(Ingen::Shared::World* world, const std::string& url) +{ + Client::HTTPEngineSender* hes = new Client::HTTPEngineSender(world, url); + hes->attach(rand(), true); + return SharedPtr<Shared::EngineInterface>(hes); +} #endif - cerr << "WARNING: Unknown URI scheme '" << scheme << "'" << endl; - return SharedPtr<Shared::EngineInterface>(); -} +struct IngenClientModule : public Ingen::Shared::Module { + void load(Ingen::Shared::World* world) { + world->interface_factories.insert(make_pair("osc.udp", &new_osc_interface)); + world->interface_factories.insert(make_pair("osc.tcp", &new_osc_interface)); + world->interface_factories.insert(make_pair("http", &new_http_interface)); + } +}; +static IngenClientModule* module = NULL; + +extern "C" { + +Ingen::Shared::Module* +ingen_module_load() { + if (!module) + module = new IngenClientModule(); + + return module; +} -} // namespace Client -} // namespace Ingen +} // extern "C" diff --git a/src/client/client.hpp b/src/client/client.hpp deleted file mode 100644 index 9ad1423a..00000000 --- a/src/client/client.hpp +++ /dev/null @@ -1,45 +0,0 @@ -/* This file is part of Ingen. - * Copyright (C) 2007-2009 Dave Robillard <http://drobilla.net> - * - * Ingen is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later - * version. - * - * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef INGEN_CLIENT_H -#define INGEN_CLIENT_H - -#include "raul/SharedPtr.hpp" - -namespace Ingen { - -class Engine; - -namespace Shared { class EngineInterface; class World; } - -namespace Client { - -extern "C" { - - SharedPtr<Shared::EngineInterface> new_remote_interface( - Shared::World* world, const std::string& url); - - SharedPtr<Shared::EngineInterface> new_queued_interface(SharedPtr<Ingen::Engine> engine); - -} - - -} // namespace Client -} // namespace Ingen - -#endif // INGEN_CLIENT_H - |