summaryrefslogtreecommitdiffstats
path: root/src/libs/client
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/client')
-rw-r--r--src/libs/client/OSCClientReceiver.cpp40
-rw-r--r--src/libs/client/OSCClientReceiver.hpp8
-rw-r--r--src/libs/client/OSCEngineSender.cpp2
-rw-r--r--src/libs/client/OSCEngineSender.hpp5
-rw-r--r--src/libs/client/SigClientInterface.hpp42
-rw-r--r--src/libs/client/ThreadedSigClientInterface.hpp45
6 files changed, 80 insertions, 62 deletions
diff --git a/src/libs/client/OSCClientReceiver.cpp b/src/libs/client/OSCClientReceiver.cpp
index 96533db2..0479cea9 100644
--- a/src/libs/client/OSCClientReceiver.cpp
+++ b/src/libs/client/OSCClientReceiver.cpp
@@ -21,8 +21,9 @@
#include <cassert>
#include <cstring>
#include <iostream>
+#include <sstream>
-using std::cerr; using std::cout; using std::endl;
+using namespace std;
using namespace Raul;
namespace Ingen {
@@ -30,14 +31,14 @@ namespace Client {
OSCClientReceiver::OSCClientReceiver(int listen_port)
-: _listen_port(listen_port),
+: ClientInterface("localhost"),
_st(NULL)//,
// _receiving_node(false),
// _receiving_node_model(NULL),
// _receiving_node_num_ports(0),
// _num_received_ports(0)
{
- start();
+ start(false);
}
@@ -48,7 +49,7 @@ OSCClientReceiver::~OSCClientReceiver()
void
-OSCClientReceiver::start()
+OSCClientReceiver::start(bool dump_osc)
{
if (_st != NULL)
return;
@@ -57,12 +58,12 @@ OSCClientReceiver::start()
if (_listen_port != 0) {
char port_str[8];
snprintf(port_str, 8, "%d", _listen_port);
- _st = lo_server_thread_new(port_str, error_cb);
+ _st = lo_server_thread_new(port_str, lo_error_cb);
}
// Find a free port
if (!_st) {
- _st = lo_server_thread_new(NULL, error_cb);
+ _st = lo_server_thread_new(NULL, lo_error_cb);
_listen_port = lo_server_thread_get_port(_st);
}
@@ -74,11 +75,9 @@ OSCClientReceiver::start()
}
// Print all incoming messages
- lo_server_thread_add_method(_st, NULL, NULL, generic_cb, NULL);
+ if (dump_osc)
+ lo_server_thread_add_method(_st, NULL, NULL, generic_cb, NULL);
- //lo_server_thread_add_method(_st, "/ingen/response/ok", "i", om_response_ok_cb, this);
- //lo_server_thread_add_method(_st, "/ingen/response/error", "is", om_responseerror_cb, this);
-
setup_callbacks();
// Display any uncaught messages to the console
@@ -122,7 +121,7 @@ OSCClientReceiver::generic_cb(const char* path, const char* types, lo_arg** argv
void
-OSCClientReceiver::error_cb(int num, const char* msg, const char* path)
+OSCClientReceiver::lo_error_cb(int num, const char* msg, const char* path)
{
cerr << "Got error from server: " << msg << endl;
}
@@ -144,7 +143,8 @@ OSCClientReceiver::unknown_cb(const char* path, const char* types, lo_arg** argv
void
OSCClientReceiver::setup_callbacks()
{
- lo_server_thread_add_method(_st, "/ingen/response", "iis", response_cb, this);
+ lo_server_thread_add_method(_st, "/ingen/ok", "i", response_ok_cb, this);
+ lo_server_thread_add_method(_st, "/ingen/error", "is", response_error_cb, this);
lo_server_thread_add_method(_st, "/ingen/num_plugins", "i", num_plugins_cb, this);
lo_server_thread_add_method(_st, "/ingen/plugin", "sss", plugin_cb, this);
lo_server_thread_add_method(_st, "/ingen/new_patch", "si", new_patch_cb, this);
@@ -366,10 +366,20 @@ OSCClientReceiver::_control_change_cb(const char* path, const char* types, lo_ar
int
-OSCClientReceiver::_response_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
+OSCClientReceiver::_response_ok_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
+{
+ assert(!strcmp(types, "i"));
+ response_ok(argv[0]->i);
+
+ return 0;
+}
+
+
+int
+OSCClientReceiver::_response_error_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
{
- assert(!strcmp(types, "iis"));
- response(argv[0]->i, argv[1]->i, &argv[2]->s);
+ assert(!strcmp(types, "is"));
+ response_error(argv[0]->i, &argv[1]->s);
return 0;
}
diff --git a/src/libs/client/OSCClientReceiver.hpp b/src/libs/client/OSCClientReceiver.hpp
index b27e7f78..45273201 100644
--- a/src/libs/client/OSCClientReceiver.hpp
+++ b/src/libs/client/OSCClientReceiver.hpp
@@ -66,7 +66,7 @@ public:
//void enable() {}
//void disable() {}
- void start();
+ void start(bool dump_osc);
void stop();
int listen_port() { return _listen_port; }
@@ -75,7 +75,8 @@ public:
private:
void setup_callbacks();
- static void error_cb(int num, const char* msg, const char* path);
+ static void lo_error_cb(int num, const char* msg, const char* path);
+
static int generic_cb(const char* path, const char* types, lo_arg** argv, int argc, void* data, void* user_data);
static int unknown_cb(const char* path, const char* types, lo_arg** argv, int argc, void* data, void* osc_receiver);
@@ -83,7 +84,8 @@ private:
lo_server_thread _st;
LO_HANDLER(error);
- LO_HANDLER(response);
+ LO_HANDLER(response_ok);
+ LO_HANDLER(response_error);
LO_HANDLER(num_plugins);
LO_HANDLER(plugin);
LO_HANDLER(plugin_list_end);
diff --git a/src/libs/client/OSCEngineSender.cpp b/src/libs/client/OSCEngineSender.cpp
index 553b073c..76b094a0 100644
--- a/src/libs/client/OSCEngineSender.cpp
+++ b/src/libs/client/OSCEngineSender.cpp
@@ -107,7 +107,7 @@ OSCEngineSender::attach(int32_t ping_id, bool block)
* traversal. It is a parameter to remain compatible with EngineInterface.
*/
void
-OSCEngineSender::register_client(const string& uri, ClientInterface* client)
+OSCEngineSender::register_client(ClientInterface* client)
{
// FIXME: use parameters.. er, somehow.
assert(_engine_addr);
diff --git a/src/libs/client/OSCEngineSender.hpp b/src/libs/client/OSCEngineSender.hpp
index b1a3ae1e..fc3c100d 100644
--- a/src/libs/client/OSCEngineSender.hpp
+++ b/src/libs/client/OSCEngineSender.hpp
@@ -22,11 +22,9 @@
#include <string>
#include <lo/lo.h>
#include "interface/EngineInterface.hpp"
-#include "interface/Responder.hpp"
using std::string;
using Ingen::Shared::EngineInterface;
using Ingen::Shared::ClientInterface;
-using Ingen::Shared::Responder;
namespace Ingen {
namespace Client {
@@ -51,7 +49,6 @@ public:
inline size_t next_id()
{ int32_t ret = (_id == -1) ? -1 : _id++; return ret; }
- void set_responder(SharedPtr<Responder> responder) { throw; }
void set_next_response_id(int32_t id) { _id = id; }
void disable_responses() { _id = -1; }
@@ -61,7 +58,7 @@ public:
/* *** EngineInterface implementation below here *** */
// Client registration
- void register_client(const string& uri, ClientInterface* client);
+ void register_client(ClientInterface* client);
void unregister_client(const string& uri);
diff --git a/src/libs/client/SigClientInterface.hpp b/src/libs/client/SigClientInterface.hpp
index 58a3297a..bdb1ff23 100644
--- a/src/libs/client/SigClientInterface.hpp
+++ b/src/libs/client/SigClientInterface.hpp
@@ -43,7 +43,8 @@ public:
// Signal parameters match up directly with ClientInterface calls
- sigc::signal<void, int32_t, bool, string> response_sig;
+ sigc::signal<void, int32_t> response_ok_sig;
+ sigc::signal<void, int32_t, string> response_error_sig;
sigc::signal<void> bundle_begin_sig;
sigc::signal<void> bundle_end_sig;
sigc::signal<void, string> error_sig;
@@ -80,55 +81,58 @@ protected:
void num_plugins(uint32_t num) { num_plugins_sig.emit(num); }
- void response(int32_t id, bool success, string msg)
- { response_sig.emit(id, success, msg); }
+ void response_ok(int32_t id)
+ { response_ok_sig.emit(id); }
- void error(string msg)
+ void response_error(int32_t id, const string& msg)
+ { response_error_sig.emit(id, msg); }
+
+ void error(const string& msg)
{ error_sig.emit(msg); }
- void new_plugin(string uri, string type_uri, string name)
+ void new_plugin(const string& uri, const string& type_uri, const string& name)
{ new_plugin_sig.emit(uri, type_uri, name); }
- void new_patch(string path, uint32_t poly)
+ void new_patch(const string& path, uint32_t poly)
{ new_patch_sig.emit(path, poly); }
- void new_node(string plugin_uri, string node_path, bool is_polyphonic, uint32_t num_ports)
+ void new_node(const string& plugin_uri, const string& node_path, bool is_polyphonic, uint32_t num_ports)
{ new_node_sig.emit(plugin_uri, node_path, is_polyphonic, num_ports); }
- void new_port(string path, string data_type, bool is_output)
+ void new_port(const string& path, const string& data_type, bool is_output)
{ new_port_sig.emit(path, data_type, is_output); }
- void connection(string src_port_path, string dst_port_path)
+ void connection(const string& src_port_path, const string& dst_port_path)
{ connection_sig.emit(src_port_path, dst_port_path); }
- void object_destroyed(string path)
+ void object_destroyed(const string& path)
{ object_destroyed_sig.emit(path); }
- void patch_enabled(string path)
+ void patch_enabled(const string& path)
{ patch_enabled_sig.emit(path); }
- void patch_disabled(string path)
+ void patch_disabled(const string& path)
{ patch_disabled_sig.emit(path); }
- void patch_cleared(string path)
+ void patch_cleared(const string& path)
{ patch_cleared_sig.emit(path); }
- void object_renamed(string old_path, string new_path)
+ void object_renamed(const string& old_path, const string& new_path)
{ object_renamed_sig.emit(old_path, new_path); }
- void disconnection(string src_port_path, string dst_port_path)
+ void disconnection(const string& src_port_path, const string& dst_port_path)
{ disconnection_sig.emit(src_port_path, dst_port_path); }
- void metadata_update(string path, string key, Raul::Atom value)
+ void metadata_update(const string& path, const string& key, const Raul::Atom& value)
{ metadata_update_sig.emit(path, key, value); }
- void control_change(string port_path, float value)
+ void control_change(const string& port_path, float value)
{ control_change_sig.emit(port_path, value); }
- void program_add(string path, uint32_t bank, uint32_t program, string name)
+ void program_add(const string& path, uint32_t bank, uint32_t program, const string& name)
{ program_add_sig.emit(path, bank, program, name); }
- void program_remove(string path, uint32_t bank, uint32_t program)
+ void program_remove(const string& path, uint32_t bank, uint32_t program)
{ program_remove_sig.emit(path, bank, program); }
protected:
diff --git a/src/libs/client/ThreadedSigClientInterface.hpp b/src/libs/client/ThreadedSigClientInterface.hpp
index af321cab..ed9f0ed4 100644
--- a/src/libs/client/ThreadedSigClientInterface.hpp
+++ b/src/libs/client/ThreadedSigClientInterface.hpp
@@ -47,7 +47,8 @@ public:
ThreadedSigClientInterface(uint32_t queue_size)
: _enabled(true)
, _sigs(queue_size)
- , response_slot(response_sig.make_slot())
+ , response_ok_slot(response_ok_sig.make_slot())
+ , response_error_slot(response_error_sig.make_slot())
, error_slot(error_sig.make_slot())
, new_plugin_slot(new_plugin_sig.make_slot())
, new_patch_slot(new_patch_sig.make_slot())
@@ -82,55 +83,58 @@ public:
void num_plugins(uint32_t num) { _num_plugins = num; }
- void response(int32_t id, bool success, string msg)
- { push_sig(sigc::bind(response_slot, id, success, msg)); }
+ void response_ok(int32_t id)
+ { push_sig(sigc::bind(response_ok_slot, id)); }
+
+ void response_error(int32_t id, const string& msg)
+ { push_sig(sigc::bind(response_error_slot, id, msg)); }
- void error(string msg)
+ void error(const string& msg)
{ push_sig(sigc::bind(error_slot, msg)); }
- void new_plugin(string uri, string type_uri, string name)
+ void new_plugin(const string& uri, const string& type_uri, const string& name)
{ push_sig(sigc::bind(new_plugin_slot, uri, type_uri, name)); }
- void new_patch(string path, uint32_t poly)
+ void new_patch(const string& path, uint32_t poly)
{ push_sig(sigc::bind(new_patch_slot, path, poly)); }
- void new_node(string plugin_uri, string node_path, bool is_polyphonic, uint32_t num_ports)
+ void new_node(const string& plugin_uri, const string& node_path, bool is_polyphonic, uint32_t num_ports)
{ push_sig(sigc::bind(new_node_slot, plugin_uri, node_path, is_polyphonic, num_ports)); }
- void new_port(string path, string data_type, bool is_output)
+ void new_port(const string& path, const string& data_type, bool is_output)
{ push_sig(sigc::bind(new_port_slot, path, data_type, is_output)); }
- void connection(string src_port_path, string dst_port_path)
+ void connection(const string& src_port_path, const string& dst_port_path)
{ push_sig(sigc::bind(connection_slot, src_port_path, dst_port_path)); }
- void object_destroyed(string path)
+ void object_destroyed(const string& path)
{ push_sig(sigc::bind(object_destroyed_slot, path)); }
- void patch_enabled(string path)
+ void patch_enabled(const string& path)
{ push_sig(sigc::bind(patch_enabled_slot, path)); }
- void patch_disabled(string path)
+ void patch_disabled(const string& path)
{ push_sig(sigc::bind(patch_disabled_slot, path)); }
- void patch_cleared(string path)
+ void patch_cleared(const string& path)
{ push_sig(sigc::bind(patch_cleared_slot, path)); }
- void object_renamed(string old_path, string new_path)
+ void object_renamed(const string& old_path, const string& new_path)
{ push_sig(sigc::bind(object_renamed_slot, old_path, new_path)); }
- void disconnection(string src_port_path, string dst_port_path)
+ void disconnection(const string& src_port_path, const string& dst_port_path)
{ push_sig(sigc::bind(disconnection_slot, src_port_path, dst_port_path)); }
- void metadata_update(string path, string key, Raul::Atom value)
+ void metadata_update(const string& path, const string& key, const Raul::Atom& value)
{ push_sig(sigc::bind(metadata_update_slot, path, key, value)); }
- void control_change(string port_path, float value)
+ void control_change(const string& port_path, float value)
{ push_sig(sigc::bind(control_change_slot, port_path, value)); }
- void program_add(string path, uint32_t bank, uint32_t program, string name)
+ void program_add(const string& path, uint32_t bank, uint32_t program, const string& name)
{ push_sig(sigc::bind(program_add_slot, path, bank, program, name)); }
- void program_remove(string path, uint32_t bank, uint32_t program)
+ void program_remove(const string& path, uint32_t bank, uint32_t program)
{ push_sig(sigc::bind(program_remove_slot, path, bank, program)); }
/** Process all queued events - Called from GTK thread to emit signals. */
@@ -147,7 +151,8 @@ private:
sigc::slot<void> bundle_begin_slot;
sigc::slot<void> bundle_end_slot;
sigc::slot<void, uint32_t> num_plugins_slot;
- sigc::slot<void, int32_t, bool, string> response_slot;
+ sigc::slot<void, int32_t> response_ok_slot;
+ sigc::slot<void, int32_t, string> response_error_slot;
sigc::slot<void, string> error_slot;
sigc::slot<void, string, string, string> new_plugin_slot;
sigc::slot<void, string, uint32_t> new_patch_slot;