summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-11-24 18:06:52 +0000
committerDavid Robillard <d@drobilla.net>2011-11-24 18:06:52 +0000
commit833c93cbde3c7829091a34204435b995a2f5e387 (patch)
treebc03ad4c27c78118098072a55f5566042eb80243 /src
parent998fc10a1f8358b455960ecafee9910a0ea906d3 (diff)
downloadingen-833c93cbde3c7829091a34204435b995a2f5e387.tar.gz
ingen-833c93cbde3c7829091a34204435b995a2f5e387.tar.bz2
ingen-833c93cbde3c7829091a34204435b995a2f5e387.zip
Remove client from world.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@3619 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r--src/http/HTTPClientReceiver.cpp26
-rw-r--r--src/http/HTTPClientReceiver.hpp7
-rw-r--r--src/http/HTTPEngineSender.cpp14
-rw-r--r--src/http/HTTPEngineSender.hpp2
-rw-r--r--src/ingen/main.cpp6
-rw-r--r--src/shared/World.cpp3
6 files changed, 26 insertions, 32 deletions
diff --git a/src/http/HTTPClientReceiver.cpp b/src/http/HTTPClientReceiver.cpp
index 0ec5aaa4..dc1235e7 100644
--- a/src/http/HTTPClientReceiver.cpp
+++ b/src/http/HTTPClientReceiver.cpp
@@ -38,9 +38,6 @@ using namespace Serialisation;
namespace Client {
-static SoupSession* client_session = NULL;
-static HTTPClientReceiver* client_receiver = NULL;
-
HTTPClientReceiver::HTTPClientReceiver(
Shared::World* world,
const std::string& url,
@@ -49,15 +46,14 @@ HTTPClientReceiver::HTTPClientReceiver(
, _world(world)
, _url(url)
{
+ _client_session = soup_session_sync_new();
start(false);
- client_receiver = this;
+ assert(_client_session);
}
HTTPClientReceiver::~HTTPClientReceiver()
{
stop();
- if (client_receiver == this)
- client_receiver = NULL;
}
HTTPClientReceiver::Listener::Listener(HTTPClientReceiver* receiver, const std::string& uri)
@@ -106,21 +102,17 @@ HTTPClientReceiver::Listener::~Listener()
void
HTTPClientReceiver::send(SoupMessage* msg)
{
- if (!client_session) {
- LOG(debug) << "Starting session" << endl;
- client_session = soup_session_sync_new();
- }
-
+ assert(SOUP_IS_SESSION(_client_session));
assert(SOUP_IS_MESSAGE(msg));
- soup_session_queue_message(client_session, msg, message_callback, client_receiver);
+ soup_session_queue_message(_client_session, msg, message_callback, this);
}
void
HTTPClientReceiver::close_session()
{
- if (client_session) {
- SoupSession* s = client_session;
- client_session = NULL;
+ if (_client_session) {
+ SoupSession* s = _client_session;
+ _client_session = NULL;
soup_session_abort(s);
}
}
@@ -196,7 +188,7 @@ HTTPClientReceiver::message_callback(SoupSession* session, SoupMessage* msg, voi
me->_world,
me->_target.get(),
Glib::ustring(msg->response_body->data),
- path);
+ "");
}
} else if (path == "/stream") {
@@ -226,7 +218,7 @@ HTTPClientReceiver::start(bool dump)
SoupMessage* msg = soup_message_new("GET", (_url + "/stream").c_str());
assert(SOUP_IS_MESSAGE(msg));
- soup_session_queue_message(client_session, msg, message_callback, this);
+ soup_session_queue_message(_client_session, msg, message_callback, this);
}
void
diff --git a/src/http/HTTPClientReceiver.hpp b/src/http/HTTPClientReceiver.hpp
index d7165c81..39407eba 100644
--- a/src/http/HTTPClientReceiver.hpp
+++ b/src/http/HTTPClientReceiver.hpp
@@ -45,17 +45,17 @@ public:
~HTTPClientReceiver();
- static void send(SoupMessage* msg);
- static void close_session();
+ void send(SoupMessage* msg);
+ void close_session();
std::string uri() const { return _url; }
void start(bool dump);
void stop();
-private:
static void message_callback(SoupSession* session, SoupMessage* msg, void* ptr);
+private:
void update(const std::string& str);
class Listener : public Raul::Thread {
@@ -76,6 +76,7 @@ private:
SharedPtr<ClientInterface> _target;
Shared::World* _world;
const std::string _url;
+ SoupSession* _client_session;
bool _quit_flag;
};
diff --git a/src/http/HTTPEngineSender.cpp b/src/http/HTTPEngineSender.cpp
index 43a3d44c..674b2674 100644
--- a/src/http/HTTPEngineSender.cpp
+++ b/src/http/HTTPEngineSender.cpp
@@ -39,12 +39,13 @@ namespace Client {
HTTPEngineSender::HTTPEngineSender(World* world,
const URI& engine_url,
SharedPtr<Raul::Deletable> receiver)
- : _receiver(receiver)
+ : _receiver(PtrCast<HTTPClientReceiver>(receiver))
, _world(*world->rdf_world())
, _engine_url(engine_url)
, _id(0)
, _enabled(true)
{
+ assert(_receiver);
_session = soup_session_sync_new();
}
@@ -57,8 +58,9 @@ void
HTTPEngineSender::attach(int32_t ping_id, bool block)
{
LOG(debug) << "Attaching to " << _engine_url << endl;
- SoupMessage* msg = soup_message_new ("GET", _engine_url.c_str());
- HTTPClientReceiver::send(msg);
+ SoupMessage* msg = soup_message_new("GET", _engine_url.c_str());
+ soup_session_queue_message(_session, msg,
+ HTTPClientReceiver::message_callback, _receiver.get());
}
/* *** ServerInterface implementation below here *** */
@@ -175,7 +177,7 @@ HTTPEngineSender::ping()
void
HTTPEngineSender::get(const URI& uri)
{
- if (!Raul::Path::is_path(uri) && uri.scheme() != "http") {
+ if (!Raul::Path::is_path(uri) && uri.scheme() != "http" && uri.scheme() != "ingen") {
LOG(warn) << "Ignoring GET of non-HTTP URI " << uri << endl;
return;
}
@@ -186,7 +188,9 @@ HTTPEngineSender::get(const URI& uri)
cout << "Get " << request_uri << endl;
LOG(debug) << "Get " << request_uri << endl;
SoupMessage* msg = soup_message_new("GET", request_uri.c_str());
- HTTPClientReceiver::send(msg);
+ soup_session_queue_message(_session, msg,
+ HTTPClientReceiver::message_callback, _receiver.get());
+
}
} // namespace Client
diff --git a/src/http/HTTPEngineSender.hpp b/src/http/HTTPEngineSender.hpp
index 14439e39..c7296bcc 100644
--- a/src/http/HTTPEngineSender.hpp
+++ b/src/http/HTTPEngineSender.hpp
@@ -109,7 +109,7 @@ public:
void get(const Raul::URI& uri);
protected:
- SharedPtr<Raul::Deletable> _receiver;
+ SharedPtr<HTTPClientReceiver> _receiver;
SoupSession* _session;
Sord::World& _world;
diff --git a/src/ingen/main.cpp b/src/ingen/main.cpp
index 38442878..8a929458 100644
--- a/src/ingen/main.cpp
+++ b/src/ingen/main.cpp
@@ -45,7 +45,7 @@
#include "ingen/shared/Configuration.hpp"
#include "ingen/shared/World.hpp"
#include "ingen/shared/runtime_paths.hpp"
-#include "ingen/client/ThreadedSigClientInterface.hpp"
+#include "ingen/client/SigClientInterface.hpp"
#ifdef WITH_BINDINGS
#include "bindings/ingen_bindings.hpp"
#endif
@@ -156,9 +156,9 @@ main(int argc, char** argv)
ingen_try(world->load_module("http_client"),
"Unable to load HTTP client module");
#endif
-
const char* const uri = conf.option("connect").get_string();
- ingen_try((engine_interface = world->interface(uri, SharedPtr<ClientInterface>())),
+ SharedPtr<ClientInterface> client(new Client::SigClientInterface());
+ ingen_try((engine_interface = world->interface(uri, client)),
(string("Unable to create interface to `") + uri + "'").c_str());
}
diff --git a/src/shared/World.cpp b/src/shared/World.cpp
index 1e3dc46f..dee5b9b6 100644
--- a/src/shared/World.cpp
+++ b/src/shared/World.cpp
@@ -170,7 +170,6 @@ public:
SharedPtr<Serialisation::Serialiser> serialiser;
SharedPtr<Serialisation::Parser> parser;
SharedPtr<Store> store;
- SharedPtr<ClientInterface> client;
LilvWorld* lilv_world;
std::string jack_uuid;
};
@@ -191,7 +190,6 @@ void World::set_engine(SharedPtr<ServerInterface> e) { _impl->engi
void World::set_serialiser(SharedPtr<Serialisation::Serialiser> s) { _impl->serialiser = s; }
void World::set_parser(SharedPtr<Serialisation::Parser> p) { _impl->parser = p; }
void World::set_store(SharedPtr<Store> s) { _impl->store = s; }
-void World::set_client(SharedPtr<ClientInterface> c) { _impl->client = c; }
void World::set_conf(Raul::Configuration* c) { _impl->conf = c; }
int& World::argc() { return _impl->argc; }
@@ -201,7 +199,6 @@ SharedPtr<ServerInterface> World::engine() { return _impl->engin
SharedPtr<Serialisation::Serialiser> World::serialiser() { return _impl->serialiser; }
SharedPtr<Serialisation::Parser> World::parser() { return _impl->parser; }
SharedPtr<Store> World::store() { return _impl->store; }
-SharedPtr<ClientInterface> World::client() { return _impl->client; }
Raul::Configuration* World::conf() { return _impl->conf; }
LV2Features* World::lv2_features() { return _impl->lv2_features; }