diff options
-rw-r--r-- | include/ingen/ServerInterface.hpp | 4 | ||||
-rw-r--r-- | src/client/HTTPEngineSender.hpp | 2 | ||||
-rw-r--r-- | src/client/OSCEngineSender.hpp | 2 | ||||
-rw-r--r-- | src/gui/ConnectWindow.cpp | 4 | ||||
-rw-r--r-- | src/server/HTTPEngineReceiver.cpp | 22 | ||||
-rw-r--r-- | src/server/HTTPEngineReceiver.hpp | 30 | ||||
-rw-r--r-- | src/server/OSCEngineReceiver.cpp | 21 | ||||
-rw-r--r-- | src/server/OSCEngineReceiver.hpp | 27 | ||||
-rw-r--r-- | src/server/Request.hpp | 4 | ||||
-rw-r--r-- | src/server/ServerInterfaceImpl.cpp | 6 | ||||
-rw-r--r-- | src/server/ServerInterfaceImpl.hpp | 5 |
11 files changed, 57 insertions, 70 deletions
diff --git a/include/ingen/ServerInterface.hpp b/include/ingen/ServerInterface.hpp index 1b5fd56d..c779089d 100644 --- a/include/ingen/ServerInterface.hpp +++ b/include/ingen/ServerInterface.hpp @@ -39,7 +39,7 @@ public: virtual Raul::URI uri() const = 0; // Responses - virtual void set_next_response_id(int32_t id) = 0; + virtual void respond_to(ClientInterface* client, int32_t id) = 0; virtual void disable_responses() = 0; // Client registration @@ -47,9 +47,7 @@ public: virtual void unregister_client(const Raul::URI& uri) = 0; // Requests - virtual void ping() = 0; - virtual void get(const Raul::URI& uri) = 0; }; diff --git a/src/client/HTTPEngineSender.hpp b/src/client/HTTPEngineSender.hpp index 9ecf3013..14439e39 100644 --- a/src/client/HTTPEngineSender.hpp +++ b/src/client/HTTPEngineSender.hpp @@ -59,7 +59,7 @@ public: inline int32_t next_id() { int32_t ret = (_id == -1) ? -1 : _id++; return ret; } - void set_next_response_id(int32_t id) { _id = id; } + void respond_to(ClientInterface* client, int32_t id) { _id = id; } void disable_responses() { _id = -1; } void attach(int32_t ping_id, bool block); diff --git a/src/client/OSCEngineSender.hpp b/src/client/OSCEngineSender.hpp index 3aea974e..75569ec0 100644 --- a/src/client/OSCEngineSender.hpp +++ b/src/client/OSCEngineSender.hpp @@ -53,7 +53,7 @@ public: inline int32_t next_id() { int32_t ret = (_id == -1) ? -1 : _id++; return ret; } - void set_next_response_id(int32_t id) { _id = id; } + void respond_to(ClientInterface* client, int32_t id) { _id = id; } void disable_responses() { _id = -1; } void attach(int32_t ping_id, bool block); diff --git a/src/gui/ConnectWindow.cpp b/src/gui/ConnectWindow.cpp index f3987779..9ccdb192 100644 --- a/src/gui/ConnectWindow.cpp +++ b/src/gui/ConnectWindow.cpp @@ -374,7 +374,7 @@ ConnectWindow::gtk_callback() sigc::mem_fun(this, &ConnectWindow::on_response)); _ping_id = abs(rand()) / 2 * 2; // avoid -1 - App::instance().engine()->set_next_response_id(_ping_id); + App::instance().engine()->respond_to(App::instance().client().get(), _ping_id); App::instance().engine()->ping(); if (_widgets_loaded) { @@ -391,7 +391,7 @@ ConnectWindow::gtk_callback() const float ms_since_last = (now.tv_sec - last.tv_sec) * 1000.0f + (now.tv_usec - last.tv_usec) * 0.001f; if (ms_since_last > 1000) { - App::instance().engine()->set_next_response_id(_ping_id); + App::instance().engine()->respond_to(App::instance().client().get(), _ping_id); App::instance().engine()->ping(); last = now; } diff --git a/src/server/HTTPEngineReceiver.cpp b/src/server/HTTPEngineReceiver.cpp index 69859ad2..a7b4ee1f 100644 --- a/src/server/HTTPEngineReceiver.cpp +++ b/src/server/HTTPEngineReceiver.cpp @@ -27,18 +27,16 @@ #include "raul/log.hpp" #include "ingen/ClientInterface.hpp" -#include "ingen/shared/Module.hpp" +#include "ingen/ServerInterface.hpp" #include "ingen/serialisation/Parser.hpp" #include "ingen/serialisation/Serialiser.hpp" +#include "ingen/shared/Module.hpp" +#include "ingen/shared/Store.hpp" #include "ClientBroadcaster.hpp" #include "Engine.hpp" -#include "EngineStore.hpp" -#include "EventSource.hpp" #include "HTTPClientSender.hpp" #include "HTTPEngineReceiver.hpp" -#include "ServerInterfaceImpl.hpp" -#include "ThreadManager.hpp" #define LOG(s) s << "[HTTPEngineReceiver] " @@ -51,9 +49,9 @@ using namespace Serialisation; namespace Server { -HTTPEngineReceiver::HTTPEngineReceiver(Engine& engine, - SharedPtr<ServerInterfaceImpl> interface, - uint16_t port) +HTTPEngineReceiver::HTTPEngineReceiver(Engine& engine, + SharedPtr<ServerInterface> interface, + uint16_t port) : _engine(engine) , _interface(interface) , _server(soup_server_new(SOUP_SERVER_PORT, port, NULL)) @@ -67,8 +65,6 @@ HTTPEngineReceiver::HTTPEngineReceiver(Engine& engine, if (!engine.world()->parser() || !engine.world()->serialiser()) engine.world()->load_module("serialisation"); - _interface->set_name("HTTPEngineReceiver"); - _interface->start(); _receive_thread->set_name("HTTPEngineReceiver Listener"); _receive_thread->start(); } @@ -76,7 +72,6 @@ HTTPEngineReceiver::HTTPEngineReceiver(Engine& engine, HTTPEngineReceiver::~HTTPEngineReceiver() { _receive_thread->stop(); - _interface->stop(); delete _receive_thread; if (_server) { @@ -94,7 +89,7 @@ HTTPEngineReceiver::message_callback(SoupServer* server, void* data) { HTTPEngineReceiver* me = (HTTPEngineReceiver*)data; - ServerInterfaceImpl* interface = me->_interface.get(); + ServerInterface* interface = me->_interface.get(); using namespace Ingen::Shared; @@ -221,9 +216,6 @@ HTTPEngineReceiver::message_callback(SoupServer* server, } } -/** Override the semaphore driven _run method of ServerInterfaceImpl - * to wait on HTTP requests and process them immediately in this thread. - */ void HTTPEngineReceiver::ReceiveThread::_run() { diff --git a/src/server/HTTPEngineReceiver.hpp b/src/server/HTTPEngineReceiver.hpp index 9e38a0f0..e17efe05 100644 --- a/src/server/HTTPEngineReceiver.hpp +++ b/src/server/HTTPEngineReceiver.hpp @@ -29,23 +29,27 @@ typedef struct _SoupMessage SoupMessage; typedef struct SoupClientContext SoupClientContext; namespace Ingen { + +class ServerInterface; + namespace Server { -class ServerInterfaceImpl; class Engine; class HTTPEngineReceiver { public: - HTTPEngineReceiver(Engine& engine, - SharedPtr<ServerInterfaceImpl> interface, - uint16_t port); + HTTPEngineReceiver(Engine& engine, + SharedPtr<ServerInterface> interface, + uint16_t port); ~HTTPEngineReceiver(); private: struct ReceiveThread : public Raul::Thread { - explicit ReceiveThread(HTTPEngineReceiver& receiver) : _receiver(receiver) {} + explicit ReceiveThread(HTTPEngineReceiver& receiver) + : _receiver(receiver) + {} virtual void _run(); private: HTTPEngineReceiver& _receiver; @@ -53,13 +57,17 @@ private: friend class ReceiveThread; - static void message_callback(SoupServer* server, SoupMessage* msg, const char* path, - GHashTable *query, SoupClientContext* client, void* data); + static void message_callback(SoupServer* server, + SoupMessage* msg, + const char* path, + GHashTable *query, + SoupClientContext* client, + void* data); - Engine& _engine; - SharedPtr<ServerInterfaceImpl> _interface; - ReceiveThread* _receive_thread; - SoupServer* _server; + Engine& _engine; + SharedPtr<ServerInterface> _interface; + ReceiveThread* _receive_thread; + SoupServer* _server; }; } // namespace Server diff --git a/src/server/OSCEngineReceiver.cpp b/src/server/OSCEngineReceiver.cpp index 3151255c..6c462d7a 100644 --- a/src/server/OSCEngineReceiver.cpp +++ b/src/server/OSCEngineReceiver.cpp @@ -57,9 +57,9 @@ namespace Server { * See the "Client OSC Namespace Documentation" for details.</p> */ -OSCEngineReceiver::OSCEngineReceiver(Engine& engine, - SharedPtr<ServerInterfaceImpl> interface, - uint16_t port) +OSCEngineReceiver::OSCEngineReceiver(Engine& engine, + SharedPtr<ServerInterface> interface, + uint16_t port) : _engine(engine) , _interface(interface) , _server(NULL) @@ -190,19 +190,10 @@ OSCEngineReceiver::set_response_address_cb(const char* path, const char* types, const lo_address addr = lo_message_get_source(msg); char* const url = lo_address_get_url(addr); - const SharedPtr<Request> r = me->_interface->request(); - - /* Different address than last time, have to do a lookup */ - if (!r || !r->client() || strcmp(url, r->client()->uri().c_str())) { - ClientInterface* client = me->_engine.broadcaster()->client(url); - Request* req = (client) - ? new Request(client, id) - : new Request(); - me->_interface->set_request(SharedPtr<Request>(req)); - } - if (id != -1) { - me->_interface->set_next_response_id(id); + // TODO: Cache client + ClientInterface* client = me->_engine.broadcaster()->client(url); + me->_interface->respond_to(client, id); } else { me->_interface->disable_responses(); } diff --git a/src/server/OSCEngineReceiver.hpp b/src/server/OSCEngineReceiver.hpp index 66e0542a..fe16ac1a 100644 --- a/src/server/OSCEngineReceiver.hpp +++ b/src/server/OSCEngineReceiver.hpp @@ -23,16 +23,19 @@ #include <lo/lo.h> #include "raul/Thread.hpp" +#include "raul/URI.hpp" + +#include "ingen/Resource.hpp" -#include "Request.hpp" #include "ingen-config.h" namespace Ingen { +class ServerInterface; + namespace Server { class Engine; -class ServerInterfaceImpl; /* Some boilerplate killing macros... */ #define LO_HANDLER_ARGS const char* path, const char* types, lo_arg** argv, int argc, lo_message msg @@ -47,22 +50,16 @@ inline static int name##_cb(LO_HANDLER_ARGS, void* myself)\ /* FIXME: Make this receive and preprocess in the same thread? */ -/** Receives OSC messages from liblo. - * - * This inherits from ServerInterfaceImpl and calls it's own functions - * via OSC. It's not actually a directly callable ServerInterface (it's - * callable via OSC...) so it should be implemented-as-a (privately inherit) - * ServerInterfaceImpl, but it needs to be public so it's an EventSource - * the Driver can use. This probably should be fixed somehow.. +/** Receive OSC messages and call interface functions. * * \ingroup engine */ class OSCEngineReceiver { public: - OSCEngineReceiver(Engine& engine, - SharedPtr<ServerInterfaceImpl> interface, - uint16_t port); + OSCEngineReceiver(Engine& engine, + SharedPtr<ServerInterface> interface, + uint16_t port); ~OSCEngineReceiver(); @@ -122,9 +119,9 @@ private: LO_HANDLER(set_property); LO_HANDLER(property_set); - Engine& _engine; - SharedPtr<ServerInterfaceImpl> _interface; - lo_server _server; + Engine& _engine; + SharedPtr<ServerInterface> _interface; + lo_server _server; }; } // namespace Server diff --git a/src/server/Request.hpp b/src/server/Request.hpp index 98c224ad..49546b7f 100644 --- a/src/server/Request.hpp +++ b/src/server/Request.hpp @@ -45,8 +45,8 @@ public: , _id(id) {} - int32_t id() const { return _id; } - void set_id(int32_t id) { _id = id; } + int32_t id() const { return _id; } + void set_id(int32_t id) { _id = id; } ClientInterface* client() const { return _client; } void set_client(ClientInterface* client) { _client = client; } diff --git a/src/server/ServerInterfaceImpl.cpp b/src/server/ServerInterfaceImpl.cpp index fcf9cc00..bc9e56c4 100644 --- a/src/server/ServerInterfaceImpl.cpp +++ b/src/server/ServerInterfaceImpl.cpp @@ -60,10 +60,12 @@ ServerInterfaceImpl::now() const } void -ServerInterfaceImpl::set_next_response_id(int32_t id) +ServerInterfaceImpl::respond_to(ClientInterface* client, int32_t id) { - if (_request) + if (_request) { + _request->set_client(client); _request->set_id(id); + } } void diff --git a/src/server/ServerInterfaceImpl.hpp b/src/server/ServerInterfaceImpl.hpp index 1afbafce..ba96d051 100644 --- a/src/server/ServerInterfaceImpl.hpp +++ b/src/server/ServerInterfaceImpl.hpp @@ -53,7 +53,8 @@ public: Raul::URI uri() const { return "http://drobilla.net/ns/ingen#internal"; } - void set_next_response_id(int32_t id); + virtual void respond_to(ClientInterface* client, int32_t id); + virtual void disable_responses(); // Client registration virtual void register_client(ClientInterface* client); @@ -100,8 +101,6 @@ public: SharedPtr<Request> request() { return _request; } void set_request(SharedPtr<Request> r) { _request = r; } - virtual void disable_responses(); - protected: SharedPtr<Request> _request; ///< NULL if responding disabled Engine& _engine; |