summaryrefslogtreecommitdiffstats
path: root/src/client
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2009-05-29 00:44:49 +0000
committerDavid Robillard <d@drobilla.net>2009-05-29 00:44:49 +0000
commit085f5e9c5eec12171596c47c0b70f6634dbc1402 (patch)
tree16df3f452c174bbd1f1099936dc592939a59967e /src/client
parentb3c31c94eb572063ec97f24a89e5f7f98d5eae41 (diff)
downloadingen-085f5e9c5eec12171596c47c0b70f6634dbc1402.tar.gz
ingen-085f5e9c5eec12171596c47c0b70f6634dbc1402.tar.bz2
ingen-085f5e9c5eec12171596c47c0b70f6634dbc1402.zip
Node creation via HTTP.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2045 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/client')
-rw-r--r--src/client/ClientStore.cpp2
-rw-r--r--src/client/HTTPClientReceiver.cpp3
-rw-r--r--src/client/HTTPEngineSender.cpp34
-rw-r--r--src/client/HTTPEngineSender.hpp12
-rw-r--r--src/client/client.cpp5
-rw-r--r--src/client/client.hpp6
6 files changed, 50 insertions, 12 deletions
diff --git a/src/client/ClientStore.cpp b/src/client/ClientStore.cpp
index bb501079..7a2a4ef5 100644
--- a/src/client/ClientStore.cpp
+++ b/src/client/ClientStore.cpp
@@ -327,7 +327,7 @@ ClientStore::put(const URI& uri, const Resource::Properties& properties)
p->set_properties(properties);
add_object(p);
} else {
- cerr << "WARNING: Illegal port " << path << endl;
+ cerr << "WARNING: Port " << path << " is malformed" << endl;
}
} else {
cerr << "WARNING: Ignoring object " << path << " with unknown type "
diff --git a/src/client/HTTPClientReceiver.cpp b/src/client/HTTPClientReceiver.cpp
index 6d0dbb1b..be1b6238 100644
--- a/src/client/HTTPClientReceiver.cpp
+++ b/src/client/HTTPClientReceiver.cpp
@@ -99,7 +99,7 @@ HTTPClientReceiver::Listener::Listener(HTTPClientReceiver* receiver, const std::
void
HTTPClientReceiver::update(const std::string& str)
{
- cout << _parser->parse_update(_world, _target.get(), str, ".");
+ cout << _parser->parse_update(_world, _target.get(), str, "");
}
void
@@ -180,6 +180,7 @@ HTTPClientReceiver::message_callback(SoupSession* session, SoupMessage* msg, voi
} else {
cerr << "UNKNOWN MESSAGE: " << path << endl;
+ me->update(msg->response_body->data);
}
}
diff --git a/src/client/HTTPEngineSender.cpp b/src/client/HTTPEngineSender.cpp
index 692d01fc..fa3509f6 100644
--- a/src/client/HTTPEngineSender.cpp
+++ b/src/client/HTTPEngineSender.cpp
@@ -17,8 +17,12 @@
#include <iostream>
#include <libsoup/soup.h>
+#include "raul/AtomRDF.hpp"
+#include "redlandmm/Model.hpp"
+#include "module/World.hpp"
#include "HTTPEngineSender.hpp"
+
using namespace std;
using namespace Raul;
@@ -27,8 +31,9 @@ using namespace Shared;
namespace Client {
-HTTPEngineSender::HTTPEngineSender(const URI& engine_url)
- : _engine_url(engine_url)
+HTTPEngineSender::HTTPEngineSender(const World* world, const URI& engine_url)
+ : _world(*world->rdf_world)
+ , _engine_url(engine_url)
, _id(0)
, _enabled(true)
{
@@ -103,11 +108,32 @@ HTTPEngineSender::quit()
// Object commands
+void
+HTTPEngineSender::message_callback(SoupSession* session, SoupMessage* msg, void* ptr)
+{
+ cerr << "HTTP CALLBACK" << endl;
+}
+
void
-HTTPEngineSender::put(const Raul::URI& path,
- const Shared::Resource::Properties& properties)
+HTTPEngineSender::put(const URI& uri,
+ const Resource::Properties& properties)
{
+ const string path = (uri.substr(0, 6) == "path:/") ? uri.substr(6) : uri.str();
+ const string full_uri = _engine_url.str() + "/" + path;
+
+ Redland::Model model(_world);
+ for (Resource::Properties::const_iterator i = properties.begin(); i != properties.end(); ++i)
+ model.add_statement(
+ Redland::Resource(_world, path),
+ i->first.str(),
+ AtomRDF::atom_to_node(_world, i->second));
+
+ const string str = model.serialise_to_string();
+ SoupMessage* msg = soup_message_new("PUT", full_uri.c_str());
+ assert(msg);
+ soup_message_set_request(msg, "application/x-turtle", SOUP_MEMORY_COPY, str.c_str(), str.length());
+ soup_session_send_message(_session, msg);
}
diff --git a/src/client/HTTPEngineSender.hpp b/src/client/HTTPEngineSender.hpp
index 00df2d7e..b5f8cfa5 100644
--- a/src/client/HTTPEngineSender.hpp
+++ b/src/client/HTTPEngineSender.hpp
@@ -23,8 +23,12 @@
#include <libsoup/soup.h>
#include "raul/Path.hpp"
#include "interface/EngineInterface.hpp"
+#include "redlandmm/World.hpp"
namespace Ingen {
+
+namespace Shared { class World; }
+
namespace Client {
@@ -35,9 +39,10 @@ namespace Client {
*
* \ingroup IngenClient
*/
-class HTTPEngineSender : public Shared::EngineInterface {
+class HTTPEngineSender : public Shared::EngineInterface
+{
public:
- HTTPEngineSender(const Raul::URI& engine_url);
+ HTTPEngineSender(const Shared::World* world, const Raul::URI& engine_url);
~HTTPEngineSender();
Raul::URI uri() const { return _engine_url; }
@@ -115,7 +120,10 @@ public:
void request_all_objects();
protected:
+ static void message_callback(SoupSession* session, SoupMessage* msg, void* ptr);
+
SoupSession* _session;
+ Redland::World& _world;
const Raul::URI _engine_url;
int _client_port;
int32_t _id;
diff --git a/src/client/client.cpp b/src/client/client.cpp
index 3ced5f63..53d7810f 100644
--- a/src/client/client.cpp
+++ b/src/client/client.cpp
@@ -26,6 +26,7 @@
#include "HTTPEngineSender.hpp"
#endif
+
using namespace std;
namespace Ingen {
@@ -33,7 +34,7 @@ namespace Client {
SharedPtr<Ingen::Shared::EngineInterface>
-new_remote_interface(const std::string& url)
+new_remote_interface(Ingen::Shared::World* world, const std::string& url)
{
const string scheme = url.substr(0, url.find(":"));
@@ -47,7 +48,7 @@ new_remote_interface(const std::string& url)
#ifdef HAVE_SOUP
if (scheme == "http") {
- HTTPEngineSender* hes = new HTTPEngineSender(url);
+ HTTPEngineSender* hes = new HTTPEngineSender(world, url);
hes->attach(rand(), true);
return SharedPtr<Shared::EngineInterface>(hes);
}
diff --git a/src/client/client.hpp b/src/client/client.hpp
index b2543c22..9ad1423a 100644
--- a/src/client/client.hpp
+++ b/src/client/client.hpp
@@ -24,13 +24,15 @@ namespace Ingen {
class Engine;
-namespace Shared { class EngineInterface; }
+namespace Shared { class EngineInterface; class World; }
namespace Client {
extern "C" {
- SharedPtr<Shared::EngineInterface> new_remote_interface(const std::string& url);
+ SharedPtr<Shared::EngineInterface> new_remote_interface(
+ Shared::World* world, const std::string& url);
+
SharedPtr<Shared::EngineInterface> new_queued_interface(SharedPtr<Ingen::Engine> engine);
}