From 90386cd6f49e2e9bfb11e7596ae6ce3ac51dfe16 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 29 May 2009 03:48:09 +0000 Subject: Fix reconnecting to engine via various protocols (inferred from user URI) in GUI. Separate HTTP client receiver and sender sanely. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2048 a436a847-0d15-0410-975c-d299462d15a1 --- src/gui/ConnectWindow.cpp | 50 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 36 insertions(+), 14 deletions(-) (limited to 'src/gui') diff --git a/src/gui/ConnectWindow.cpp b/src/gui/ConnectWindow.cpp index e68f020e..80ac0de3 100644 --- a/src/gui/ConnectWindow.cpp +++ b/src/gui/ConnectWindow.cpp @@ -31,6 +31,7 @@ #include "engine/Driver.hpp" #ifdef HAVE_SOUP #include "client/HTTPClientReceiver.hpp" +#include "client/HTTPEngineSender.hpp" #endif #ifdef HAVE_LIBLO #include "client/OSCClientReceiver.hpp" @@ -164,30 +165,51 @@ ConnectWindow::connect(bool existing) Ingen::Shared::World* world = App::instance().world(); -#ifdef HAVE_LIBLO +#if defined(HAVE_LIBLO) || defined(HAVE_SOUP) if (_mode == CONNECT_REMOTE) { - if (!existing) { - Raul::URI engine_url("http://localhost:16180"); - if (_widgets_loaded) { - const std::string& url_str = _url_entry->get_text(); - if (Raul::URI::is_valid(url_str)) - engine_url = url_str; - } - world->engine = SharedPtr(new OSCEngineSender(engine_url)); +#ifdef HAVE_LIBLO + string uri = "osc.udp://localhost:16180"; +#else + string uri = "http://localhost:16180"; +#endif + if (_widgets_loaded) { + const std::string& user_uri = _url_entry->get_text(); + if (Raul::URI::is_valid(user_uri)) + uri = user_uri; } + if (existing) + uri = world->engine->uri().str(); + + // Create client-side listener SharedPtr tsci(new ThreadedSigClientInterface(1024)); SharedPtr client; - const string& uri = world->engine->uri().str(); - const string& scheme = uri.substr(0, uri.find(":")); + string scheme = uri.substr(0, uri.find(":")); + +#ifdef HAVE_LIBLO if (scheme == "osc.udp" || scheme == "osc.tcp") - client = SharedPtr(new OSCClientReceiver(16181, tsci)); // FIXME: port + client = SharedPtr(new OSCClientReceiver(16181, tsci)); +#endif #ifdef HAVE_SOUP - else if (scheme == "http") + if (scheme == "http") client = SharedPtr(new HTTPClientReceiver(world, uri, tsci)); #endif + if (!existing) { +#ifdef HAVE_LIBLO + if (scheme == "osc.udp" || scheme == "osc.tcp") + world->engine = SharedPtr(new OSCEngineSender(uri)); +#endif +#ifdef HAVE_SOUP + if (scheme == "http") + world->engine = SharedPtr(new HTTPEngineSender(world, uri)); +#endif + } else { + uri = world->engine->uri().str(); + scheme = uri.substr(0, uri.find(":")); + } + App::instance().attach(tsci, client); App::instance().register_callbacks(); @@ -220,7 +242,7 @@ ConnectWindow::connect(bool existing) } } else -#endif +#endif // defined(HAVE_LIBLO) || defined(HAVE_SOUP) if (_mode == INTERNAL) { if ( ! world->local_engine) { assert(_new_engine); -- cgit v1.2.1