summaryrefslogtreecommitdiffstats
path: root/src/client
diff options
context:
space:
mode:
Diffstat (limited to 'src/client')
-rw-r--r--src/client/ClientStore.cpp25
-rw-r--r--src/client/ClientStore.hpp1
-rw-r--r--src/client/HTTPClientReceiver.cpp29
-rw-r--r--src/client/HTTPClientReceiver.hpp12
-rw-r--r--src/client/OSCEngineSender.cpp29
-rw-r--r--src/client/OSCEngineSender.hpp2
-rw-r--r--src/client/SigClientInterface.hpp4
-rw-r--r--src/client/ThreadedSigClientInterface.cpp29
-rw-r--r--src/client/ThreadedSigClientInterface.hpp2
9 files changed, 120 insertions, 13 deletions
diff --git a/src/client/ClientStore.cpp b/src/client/ClientStore.cpp
index cf9e06a0..4c4e452c 100644
--- a/src/client/ClientStore.cpp
+++ b/src/client/ClientStore.cpp
@@ -429,6 +429,31 @@ ClientStore::new_plugin(const string& uri, const string& type_uri, const string&
void
+ClientStore::new_object(const Shared::GraphObject* object)
+{
+ using namespace Shared;
+
+ const Patch* patch = dynamic_cast<const Patch*>(object);
+ if (patch) {
+ new_patch(patch->path(), patch->internal_polyphony());
+ return;
+ }
+
+ const Node* node = dynamic_cast<const Node*>(object);
+ if (node) {
+ new_node(node->path(), node->plugin()->uri());
+ return;
+ }
+
+ const Port* port = dynamic_cast<const Port*>(object);
+ if (port) {
+ new_port(port->path(), port->type().uri(), port->index(), !port->is_input());
+ return;
+ }
+}
+
+
+void
ClientStore::new_patch(const string& path, uint32_t poly)
{
SharedPtr<PatchModel> p(new PatchModel(path, poly));
diff --git a/src/client/ClientStore.hpp b/src/client/ClientStore.hpp
index 944ab752..2387f519 100644
--- a/src/client/ClientStore.hpp
+++ b/src/client/ClientStore.hpp
@@ -70,6 +70,7 @@ public:
// CommonInterface
void new_plugin(const string& uri, const string& type_uri, const string& symbol, const string& name);
+ void new_object(const Shared::GraphObject* object);
void new_patch(const string& path, uint32_t poly);
void new_node(const string& path, const string& plugin_uri);
void new_port(const string& path, const string& type, uint32_t index, bool is_output);
diff --git a/src/client/HTTPClientReceiver.cpp b/src/client/HTTPClientReceiver.cpp
index 572ff548..b314a7b7 100644
--- a/src/client/HTTPClientReceiver.cpp
+++ b/src/client/HTTPClientReceiver.cpp
@@ -56,9 +56,9 @@ HTTPClientReceiver::Listener::~Listener()
close(_sock);
}
-HTTPClientReceiver::Listener::Listener(SoupSession* session, const std::string uri)
+HTTPClientReceiver::Listener::Listener(HTTPClientReceiver* receiver, const std::string uri)
: _uri(uri)
- , _session(session)
+ , _receiver(receiver)
{
string port_str = uri.substr(uri.find_last_of(":")+1);
int port = atoi(port_str.c_str());
@@ -94,25 +94,34 @@ HTTPClientReceiver::Listener::Listener(SoupSession* session, const std::string u
}
}
+void
+HTTPClientReceiver::update(const std::string& str)
+{
+ cout << "UPDATE: " << str << endl;
+ cout << _parser->parse_string(_world, _target.get(), str, "/", "/");
+}
void
HTTPClientReceiver::Listener::_run()
{
- char in = '\0';
- char last = '\0';
- string recv = "";
+ char in = '\0';
+ char last = '\0';
+ char llast = '\0';
+ string recv = "";
while (true) {
while (read(_sock, &in, 1) > 0 ) {
recv += in;
- if (last == '\n' && in == '\n') {
+ if (in == '\n' && last == '\n' && llast == '\n') {
if (recv != "") {
- cout << "RECEIVED UPDATE:\n" << recv << endl;
+ _receiver->update(recv);
recv = "";
last = '\0';
+ llast = '\0';
}
break;
}
+ llast = last;
last = in;
}
}
@@ -129,11 +138,13 @@ HTTPClientReceiver::message_callback(SoupSession* session, SoupMessage* msg, voi
if (path == "/") {
me->_target->response_ok(0);
me->_target->enable();
+
} else if (path == "/plugins") {
if (msg->response_body->data == NULL) {
cout << "ERROR: Empty response" << endl;
} else {
+ Glib::Mutex::Lock lock(me->_mutex);
me->_target->response_ok(0);
me->_target->enable();
me->_parser->parse_string(me->_world, me->_target.get(),
@@ -145,6 +156,7 @@ HTTPClientReceiver::message_callback(SoupSession* session, SoupMessage* msg, voi
if (msg->response_body->data == NULL) {
cout << "ERROR: Empty response" << endl;
} else {
+ Glib::Mutex::Lock lock(me->_mutex);
me->_target->response_ok(0);
me->_target->enable();
me->_parser->parse_string(me->_world, me->_target.get(),
@@ -156,11 +168,12 @@ HTTPClientReceiver::message_callback(SoupSession* session, SoupMessage* msg, voi
if (msg->response_body->data == NULL) {
cout << "ERROR: Empty response" << endl;
} else {
+ Glib::Mutex::Lock lock(me->_mutex);
string uri = string(soup_uri_to_string(soup_message_get_uri(msg), false));
uri = uri.substr(0, uri.find_last_of(":"));
uri += string(":") + msg->response_body->data;
cout << "Stream URI: " << uri << endl;
- me->_listener = boost::shared_ptr<Listener>(new Listener(me->_session, uri));
+ me->_listener = boost::shared_ptr<Listener>(new Listener(me, uri));
me->_listener->start();
}
diff --git a/src/client/HTTPClientReceiver.hpp b/src/client/HTTPClientReceiver.hpp
index 015a551f..60b458ac 100644
--- a/src/client/HTTPClientReceiver.hpp
+++ b/src/client/HTTPClientReceiver.hpp
@@ -21,6 +21,7 @@
#include <cstdlib>
#include <boost/utility.hpp>
#include <libsoup/soup.h>
+#include <glibmm/thread.h>
#include "redlandmm/World.hpp"
#include "raul/Deletable.hpp"
#include "raul/Thread.hpp"
@@ -48,20 +49,23 @@ public:
private:
static void message_callback(SoupSession* session, SoupMessage* msg, void* ptr);
+ void update(const std::string& str);
+
class Listener : public Raul::Thread {
public:
- Listener(SoupSession* session, const std::string uri);
+ Listener(HTTPClientReceiver* receiver, const std::string uri);
~Listener();
void _run();
private:
- std::string _uri;
- int _sock;
- SoupSession* _session;
+ std::string _uri;
+ int _sock;
+ HTTPClientReceiver* _receiver;
};
friend class Listener;
SharedPtr<Listener> _listener;
+ Glib::Mutex _mutex;
SharedPtr<Shared::ClientInterface> _target;
Shared::World* _world;
diff --git a/src/client/OSCEngineSender.cpp b/src/client/OSCEngineSender.cpp
index 1eb9ad6e..7392f9d2 100644
--- a/src/client/OSCEngineSender.cpp
+++ b/src/client/OSCEngineSender.cpp
@@ -18,6 +18,9 @@
#include <iostream>
#include "raul/AtomLiblo.hpp"
#include "OSCEngineSender.hpp"
+#include "common/interface/Patch.hpp"
+#include "common/interface/Port.hpp"
+#include "common/interface/Plugin.hpp"
using namespace std;
using Raul::Atom;
@@ -127,6 +130,32 @@ OSCEngineSender::quit()
// Object commands
+
+void
+OSCEngineSender::new_object(const Shared::GraphObject* object)
+{
+ using namespace Shared;
+
+ const Patch* patch = dynamic_cast<const Patch*>(object);
+ if (patch) {
+ new_patch(patch->path(), patch->internal_polyphony());
+ return;
+ }
+
+ const Node* node = dynamic_cast<const Node*>(object);
+ if (node) {
+ new_node(node->path(), node->plugin()->uri());
+ return;
+ }
+
+ const Port* port = dynamic_cast<const Port*>(object);
+ if (port) {
+ new_port(port->path(), port->type().uri(), port->index(), !port->is_input());
+ return;
+ }
+}
+
+
void
OSCEngineSender::new_patch(const string& path,
uint32_t poly)
diff --git a/src/client/OSCEngineSender.hpp b/src/client/OSCEngineSender.hpp
index 12b062e4..ba851d68 100644
--- a/src/client/OSCEngineSender.hpp
+++ b/src/client/OSCEngineSender.hpp
@@ -80,6 +80,8 @@ public:
// Object commands
+ void new_object(const Shared::GraphObject* object);
+
void new_patch(const string& path,
uint32_t poly);
diff --git a/src/client/SigClientInterface.hpp b/src/client/SigClientInterface.hpp
index 36ca44b9..046dbcbb 100644
--- a/src/client/SigClientInterface.hpp
+++ b/src/client/SigClientInterface.hpp
@@ -47,6 +47,7 @@ public:
std::string uri() const { return "(internal)"; }
// Signal parameters match up directly with ClientInterface calls
+ sigc::signal<void, const Shared::GraphObject*> signal_new_object;
sigc::signal<void, int32_t> signal_response_ok;
sigc::signal<void, int32_t, string> signal_response_error;
@@ -103,6 +104,9 @@ protected:
void new_plugin(const string& uri, const string& type_uri, const string& symbol, const string& name)
{ if (_enabled) signal_new_plugin.emit(uri, type_uri, symbol, name); }
+ void new_object(const Shared::GraphObject* object)
+ { if (_enabled) signal_new_object.emit(object); }
+
void new_patch(const string& path, uint32_t poly)
{ if (_enabled) signal_new_patch.emit(path, poly); }
diff --git a/src/client/ThreadedSigClientInterface.cpp b/src/client/ThreadedSigClientInterface.cpp
index ef95133b..b430a0a0 100644
--- a/src/client/ThreadedSigClientInterface.cpp
+++ b/src/client/ThreadedSigClientInterface.cpp
@@ -15,8 +15,11 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "ThreadedSigClientInterface.hpp"
#include <iostream>
+#include "common/interface/Patch.hpp"
+#include "common/interface/Plugin.hpp"
+#include "common/interface/Port.hpp"
+#include "ThreadedSigClientInterface.hpp"
using namespace std;
@@ -74,5 +77,29 @@ ThreadedSigClientInterface::emit_signals()
}
+void
+ThreadedSigClientInterface::new_object(const Shared::GraphObject* object)
+{
+ using namespace Shared;
+ const Patch* patch = dynamic_cast<const Patch*>(object);
+ if (patch) {
+ new_patch(patch->path(), patch->internal_polyphony());
+ return;
+ }
+
+ const Node* node = dynamic_cast<const Node*>(object);
+ if (node) {
+ new_node(node->path(), node->plugin()->uri());
+ return;
+ }
+
+ const Port* port = dynamic_cast<const Port*>(object);
+ if (port) {
+ new_port(port->path(), port->type().uri(), port->index(), !port->is_input());
+ return;
+ }
+}
+
+
} // namespace Client
} // namespace Ingen
diff --git a/src/client/ThreadedSigClientInterface.hpp b/src/client/ThreadedSigClientInterface.hpp
index 968954bc..984f9cad 100644
--- a/src/client/ThreadedSigClientInterface.hpp
+++ b/src/client/ThreadedSigClientInterface.hpp
@@ -97,6 +97,8 @@ public:
void new_plugin(const string& uri, const string& type_uri, const string& symbol, const string& name)
{ push_sig(sigc::bind(new_plugin_slot, uri, type_uri, symbol, name)); }
+ void new_object(const Shared::GraphObject* object);
+
void new_patch(const string& path, uint32_t poly)
{ push_sig(sigc::bind(new_patch_slot, path, poly)); }