summaryrefslogtreecommitdiffstats
path: root/src/client
diff options
context:
space:
mode:
Diffstat (limited to 'src/client')
-rw-r--r--src/client/HTTPEngineSender.cpp7
-rw-r--r--src/client/HTTPEngineSender.hpp8
-rw-r--r--src/client/OSCClientReceiver.cpp3
-rw-r--r--src/client/OSCEngineSender.cpp6
-rw-r--r--src/client/OSCEngineSender.hpp14
-rw-r--r--src/client/ingen_client.cpp21
6 files changed, 42 insertions, 17 deletions
diff --git a/src/client/HTTPEngineSender.cpp b/src/client/HTTPEngineSender.cpp
index ec5cc6a0..2c3dbe98 100644
--- a/src/client/HTTPEngineSender.cpp
+++ b/src/client/HTTPEngineSender.cpp
@@ -36,8 +36,11 @@ using namespace Shared;
namespace Client {
-HTTPEngineSender::HTTPEngineSender(World* world, const URI& engine_url)
- : _world(*world->rdf_world())
+HTTPEngineSender::HTTPEngineSender(World* world,
+ const URI& engine_url,
+ SharedPtr<Raul::Deletable> receiver)
+ : _receiver(receiver)
+ , _world(*world->rdf_world())
, _engine_url(engine_url)
, _id(0)
, _enabled(true)
diff --git a/src/client/HTTPEngineSender.hpp b/src/client/HTTPEngineSender.hpp
index 27c34a51..3f932fb0 100644
--- a/src/client/HTTPEngineSender.hpp
+++ b/src/client/HTTPEngineSender.hpp
@@ -22,6 +22,7 @@
#include <string>
+#include "raul/Deletable.hpp"
#include "raul/Path.hpp"
#include "sord/sordmm.hpp"
@@ -47,7 +48,10 @@ class HTTPClientReceiver;
class HTTPEngineSender : public ServerInterface
{
public:
- HTTPEngineSender(Shared::World* world, const Raul::URI& engine_url);
+ HTTPEngineSender(Shared::World* world,
+ const Raul::URI& engine_url,
+ SharedPtr<Raul::Deletable> receiver);
+
~HTTPEngineSender();
Raul::URI uri() const { return _engine_url; }
@@ -106,6 +110,8 @@ public:
void request_property(const Raul::URI& path, const Raul::URI& key);
protected:
+ SharedPtr<Raul::Deletable> _receiver;
+
SoupSession* _session;
Sord::World& _world;
const Raul::URI _engine_url;
diff --git a/src/client/OSCClientReceiver.cpp b/src/client/OSCClientReceiver.cpp
index 33e2d050..c163da60 100644
--- a/src/client/OSCClientReceiver.cpp
+++ b/src/client/OSCClientReceiver.cpp
@@ -137,6 +137,9 @@ OSCClientReceiver::unknown_cb(const char* path, const char* types, lo_arg** argv
void
OSCClientReceiver::setup_callbacks()
{
+ if (!_target)
+ return;
+
lo_server_thread_add_method(_st, "/ok", "i", response_ok_cb, this);
lo_server_thread_add_method(_st, "/error", "is", response_error_cb, this);
lo_server_thread_add_method(_st, "/plugin", "sss", plugin_cb, this);
diff --git a/src/client/OSCEngineSender.cpp b/src/client/OSCEngineSender.cpp
index 4147c831..21c1ad6e 100644
--- a/src/client/OSCEngineSender.cpp
+++ b/src/client/OSCEngineSender.cpp
@@ -37,9 +37,11 @@ namespace Client {
* from the most recently created server, so create the OSC listener before
* this to have it all happen on the same port. Yeah, this is a big magic :/
*/
-OSCEngineSender::OSCEngineSender(const URI& engine_url,
- size_t max_packet_size)
+OSCEngineSender::OSCEngineSender(const URI& engine_url,
+ size_t max_packet_size,
+ SharedPtr<Raul::Deletable> receiver)
: Shared::OSCSender(max_packet_size)
+ , _receiver(receiver)
, _engine_url(engine_url)
, _id(0)
{
diff --git a/src/client/OSCEngineSender.hpp b/src/client/OSCEngineSender.hpp
index a50de0f3..876d2ec2 100644
--- a/src/client/OSCEngineSender.hpp
+++ b/src/client/OSCEngineSender.hpp
@@ -24,6 +24,8 @@
#include <lo/lo.h>
+#include "raul/Deletable.hpp"
+
#include "ingen/ServerInterface.hpp"
#include "shared/OSCSender.hpp"
@@ -40,16 +42,12 @@ namespace Client {
*/
class OSCEngineSender : public ServerInterface, public Shared::OSCSender {
public:
- OSCEngineSender(const Raul::URI& engine_url,
- size_t max_packet_size);
+ OSCEngineSender(const Raul::URI& engine_url,
+ size_t max_packet_size,
+ SharedPtr<Raul::Deletable> receiver);
~OSCEngineSender();
- static OSCEngineSender* create(const Raul::URI& engine_url,
- size_t max_packet_size) {
- return new OSCEngineSender(engine_url, max_packet_size);
- }
-
Raul::URI uri() const { return _engine_url; }
inline int32_t next_id()
@@ -106,6 +104,8 @@ public:
void request_property(const Raul::URI& path, const Raul::URI& key);
protected:
+ SharedPtr<Raul::Deletable> _receiver;
+
const Raul::URI _engine_url;
int _client_port;
int32_t _id;
diff --git a/src/client/ingen_client.cpp b/src/client/ingen_client.cpp
index dc4d7f20..db32b117 100644
--- a/src/client/ingen_client.cpp
+++ b/src/client/ingen_client.cpp
@@ -20,9 +20,11 @@
#include "shared/Module.hpp"
#include "shared/World.hpp"
#ifdef HAVE_LIBLO
+#include "OSCClientReceiver.hpp"
#include "OSCEngineSender.hpp"
#endif
#ifdef HAVE_SOUP
+#include "HTTPClientReceiver.hpp"
#include "HTTPEngineSender.hpp"
#endif
@@ -30,10 +32,14 @@ using namespace Ingen;
#ifdef HAVE_LIBLO
SharedPtr<Ingen::ServerInterface>
-new_osc_interface(Ingen::Shared::World* world, const std::string& url)
+new_osc_interface(Ingen::Shared::World* world,
+ const std::string& url,
+ SharedPtr<ClientInterface> respond_to)
{
- Client::OSCEngineSender* oes = Client::OSCEngineSender::create(
- url, world->conf()->option("packet-size").get_int32());
+ SharedPtr<Client::OSCClientReceiver> receiver(
+ new Client::OSCClientReceiver(16181, respond_to));
+ Client::OSCEngineSender* oes = new Client::OSCEngineSender(
+ url, world->conf()->option("packet-size").get_int32(), receiver);
oes->attach(rand(), true);
return SharedPtr<ServerInterface>(oes);
}
@@ -41,9 +47,14 @@ new_osc_interface(Ingen::Shared::World* world, const std::string& url)
#ifdef HAVE_SOUP
SharedPtr<Ingen::ServerInterface>
-new_http_interface(Ingen::Shared::World* world, const std::string& url)
+new_http_interface(Ingen::Shared::World* world,
+ const std::string& url,
+ SharedPtr<ClientInterface> respond_to)
{
- Client::HTTPEngineSender* hes = new Client::HTTPEngineSender(world, url);
+ SharedPtr<Client::HTTPClientReceiver> receiver(
+ new Client::HTTPClientReceiver(world, url, respond_to));
+ Client::HTTPEngineSender* hes = new Client::HTTPEngineSender(
+ world, url, receiver);
hes->attach(rand(), true);
return SharedPtr<ServerInterface>(hes);
}