From e9d9569271ee962c09ab66c6babed1ca5655a6c6 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 12 Mar 2012 02:28:21 +0000 Subject: Unify event response mechanism and make it more appropriate for wire transmission. The downside being more cryptic error messages until the client side error reporting stuff gets more fancy, but the important part is that belongs client side. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4053 a436a847-0d15-0410-975c-d299462d15a1 --- src/osc/OSCClientReceiver.cpp | 19 ++++--------------- src/osc/OSCClientReceiver.hpp | 3 +-- src/osc/OSCClientSender.cpp | 33 +++++++-------------------------- src/osc/OSCClientSender.hpp | 3 +-- 4 files changed, 13 insertions(+), 45 deletions(-) (limited to 'src/osc') diff --git a/src/osc/OSCClientReceiver.cpp b/src/osc/OSCClientReceiver.cpp index 249cf2a4..a0cd58b7 100644 --- a/src/osc/OSCClientReceiver.cpp +++ b/src/osc/OSCClientReceiver.cpp @@ -137,8 +137,7 @@ 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, "/response", "ii", response_cb, this); lo_server_thread_add_method(_st, "/plugin", "sss", plugin_cb, this); lo_server_thread_add_method(_st, "/put", NULL, put_cb, this); lo_server_thread_add_method(_st, "/delta_begin", NULL, delta_begin_cb, this); @@ -282,20 +281,10 @@ OSCClientReceiver::_activity_cb(const char* path, const char* types, lo_arg** ar } int -OSCClientReceiver::_response_ok_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg) +OSCClientReceiver::_response_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg) { - assert(!strcmp(types, "i")); - _target->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, "is")); - _target->response_error(argv[0]->i, &argv[1]->s); - + assert(!strcmp(types, "ii")); + _target->response(argv[0]->i, (Status)argv[1]->i); return 0; } diff --git a/src/osc/OSCClientReceiver.hpp b/src/osc/OSCClientReceiver.hpp index 46afc81a..a04ed5f5 100644 --- a/src/osc/OSCClientReceiver.hpp +++ b/src/osc/OSCClientReceiver.hpp @@ -66,8 +66,7 @@ private: int _listen_port; LO_HANDLER(OSCClientReceiver, error); - LO_HANDLER(OSCClientReceiver, response_ok); - LO_HANDLER(OSCClientReceiver, response_error); + LO_HANDLER(OSCClientReceiver, response); LO_HANDLER(OSCClientReceiver, plugin); LO_HANDLER(OSCClientReceiver, plugin_list_end); LO_HANDLER(OSCClientReceiver, new_patch); diff --git a/src/osc/OSCClientSender.cpp b/src/osc/OSCClientSender.cpp index a0b7979c..1a6289f4 100644 --- a/src/osc/OSCClientSender.cpp +++ b/src/osc/OSCClientSender.cpp @@ -39,41 +39,22 @@ namespace Server { */ /** @page client_osc_namespace - *

/ok

+ *

/response

* @arg @p response-id :: Integer + * @arg @p status :: Integer * * @par - * Successful response to some command. + * Response to some command. */ void -OSCClientSender::response_ok(int32_t id) -{ - if (!_enabled) - return; - - if (lo_send(_address, "/ok", "i", id, LO_ARGS_END) < 0) { - Raul::error << "Unable to send OK " << id << "! (" - << lo_address_errstr(_address) << ")" << endl; - } -} - -/** @page client_osc_namespace - *

/error

- * @arg @p response-id :: Integer - * @arg @p message :: String - * - * @par - * Unsuccessful response to some command. - */ -void -OSCClientSender::response_error(int32_t id, const std::string& msg) +OSCClientSender::response(int32_t id, Status status) { if (!_enabled) return; - if (lo_send(_address, "/error", "is", id, msg.c_str(), LO_ARGS_END) < 0) { - Raul::error << "Unable to send error " << id << "! (" - << lo_address_errstr(_address) << ")" << endl; + if (lo_send(_address, "/response", "ii", id, status, LO_ARGS_END) < 0) { + Raul::error << "Unable to send response " << id << "! (" + << lo_address_errstr(_address) << ")" << endl; } } diff --git a/src/osc/OSCClientSender.hpp b/src/osc/OSCClientSender.hpp index c391e54a..67e76fee 100644 --- a/src/osc/OSCClientSender.hpp +++ b/src/osc/OSCClientSender.hpp @@ -66,8 +66,7 @@ public: /* *** ClientInterface Implementation Below *** */ - void response_ok(int32_t id); - void response_error(int32_t id, const std::string& msg); + void response(int32_t id, Status status); void error(const std::string& msg); -- cgit v1.2.1