diff options
author | David Robillard <d@drobilla.net> | 2011-10-21 21:45:14 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2011-10-21 21:45:14 +0000 |
commit | 0d4792af695d94a1e476adcdb65eed8a501ddbd4 (patch) | |
tree | 1c0fc824541fcdbb057f5a0909bc8cf7704dccfe /src/server/HTTPEngineReceiver.cpp | |
parent | 4ce6781bd6727fca68d4c99337f47a75d849e5ab (diff) | |
download | ingen-0d4792af695d94a1e476adcdb65eed8a501ddbd4.tar.gz ingen-0d4792af695d94a1e476adcdb65eed8a501ddbd4.tar.bz2 ingen-0d4792af695d94a1e476adcdb65eed8a501ddbd4.zip |
Make OSCEngineReceiver and HTTPEngineReceiver has-a ServerInterfaceImpl (instead of is-a).
Towards further modularization...
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@3570 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/server/HTTPEngineReceiver.cpp')
-rw-r--r-- | src/server/HTTPEngineReceiver.cpp | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/src/server/HTTPEngineReceiver.cpp b/src/server/HTTPEngineReceiver.cpp index 15362a80..62882bf2 100644 --- a/src/server/HTTPEngineReceiver.cpp +++ b/src/server/HTTPEngineReceiver.cpp @@ -37,6 +37,7 @@ #include "EventSource.hpp" #include "HTTPClientSender.hpp" #include "HTTPEngineReceiver.hpp" +#include "ServerInterfaceImpl.hpp" #include "ThreadManager.hpp" #define LOG(s) s << "[HTTPEngineReceiver] " @@ -50,8 +51,11 @@ using namespace Serialisation; namespace Server { -HTTPEngineReceiver::HTTPEngineReceiver(Engine& engine, uint16_t port) - : ServerInterfaceImpl(engine) +HTTPEngineReceiver::HTTPEngineReceiver(Engine& engine, + SharedPtr<ServerInterfaceImpl> interface, + uint16_t port) + : _engine(engine) + , _interface(interface) , _server(soup_server_new(SOUP_SERVER_PORT, port, NULL)) { _receive_thread = new ReceiveThread(*this); @@ -63,8 +67,8 @@ HTTPEngineReceiver::HTTPEngineReceiver(Engine& engine, uint16_t port) if (!engine.world()->parser() || !engine.world()->serialiser()) engine.world()->load_module("serialisation"); - Thread::set_name("HTTPEngineReceiver"); - start(); + _interface->set_name("HTTPEngineReceiver"); + _interface->start(); _receive_thread->set_name("HTTPEngineReceiver Listener"); _receive_thread->start(); } @@ -72,7 +76,7 @@ HTTPEngineReceiver::HTTPEngineReceiver(Engine& engine, uint16_t port) HTTPEngineReceiver::~HTTPEngineReceiver() { _receive_thread->stop(); - stop(); + _interface->stop(); delete _receive_thread; if (_server) { @@ -82,6 +86,12 @@ HTTPEngineReceiver::~HTTPEngineReceiver() } void +HTTPEngineReceiver::ReceiveThread::whip() +{ + _receiver._interface->prepare_all(); +} + +void HTTPEngineReceiver::message_callback(SoupServer* server, SoupMessage* msg, const char* path_str, @@ -89,7 +99,8 @@ HTTPEngineReceiver::message_callback(SoupServer* server, SoupClientContext* client, void* data) { - HTTPEngineReceiver* me = (HTTPEngineReceiver*)data; + HTTPEngineReceiver* me = (HTTPEngineReceiver*)data; + ServerInterfaceImpl* interface = me->_interface.get(); using namespace Ingen::Shared; @@ -123,7 +134,7 @@ HTTPEngineReceiver::message_callback(SoupServer* server, } else if (msg->method == SOUP_METHOD_GET && path.substr(0, 8) == "/plugins") { // FIXME: kludge #if 0 - me->get("ingen:plugins"); + interface->get("ingen:plugins"); me->_receive_thread->whip(); serialiser->start_to_string("/", base_uri); @@ -143,7 +154,7 @@ HTTPEngineReceiver::message_callback(SoupServer* server, } else if (path.substr(0, 7) == "/stream") { HTTPClientSender* client = new HTTPClientSender(me->_engine); - me->register_client(client); + interface->register_client(client); // Respond with port number of stream for client const int port = client->listen_port(); @@ -204,11 +215,11 @@ HTTPEngineReceiver::message_callback(SoupServer* server, return; } - parser->parse_string(me->_engine.world(), me, msg->request_body->data, base_uri); + parser->parse_string(me->_engine.world(), interface, msg->request_body->data, base_uri); soup_message_set_status(msg, SOUP_STATUS_OK); } else if (msg->method == SOUP_METHOD_DELETE) { - me->del(path); + interface->del(path); soup_message_set_status(msg, SOUP_STATUS_OK); } else { |