diff options
Diffstat (limited to 'src/socket')
-rw-r--r-- | src/socket/SocketInterface.cpp | 43 | ||||
-rw-r--r-- | src/socket/SocketInterface.hpp | 31 | ||||
-rw-r--r-- | src/socket/SocketListener.cpp | 6 | ||||
-rw-r--r-- | src/socket/ingen_socket_server.cpp | 1 |
4 files changed, 16 insertions, 65 deletions
diff --git a/src/socket/SocketInterface.cpp b/src/socket/SocketInterface.cpp index 430f0962..8b9aab66 100644 --- a/src/socket/SocketInterface.cpp +++ b/src/socket/SocketInterface.cpp @@ -24,21 +24,18 @@ #include "sratom/sratom.h" #include "SocketInterface.hpp" -#include "../server/Event.hpp" -#include "../server/PostProcessor.hpp" -#include "../server/ThreadManager.hpp" - #define LOG(s) s << "[SocketInterface] " namespace Ingen { namespace Socket { -SocketInterface::SocketInterface(Ingen::Shared::World& world, int conn) +SocketInterface::SocketInterface(Ingen::Shared::World& world, + Interface& iface, + int conn) : _world(world) - , _iface(*(Server::Engine*)world.local_engine().get(), *this) + , _iface(iface) , _inserter(NULL) , _msg_node(NULL) - , _event(NULL) , _conn(conn) { set_name("SocketInterface"); @@ -47,38 +44,11 @@ SocketInterface::SocketInterface(Ingen::Shared::World& world, int conn) SocketInterface::~SocketInterface() { - std::cerr << "SOCKET INTERFACE EXITING" << std::endl; stop(); join(); close(_conn); } -void -SocketInterface::event(Server::Event* ev) -{ - if (_event) { - std::cerr << "DUAL EVENTS" << std::endl; - return; - } - assert(!_event); - ev->pre_process(); - _event = ev; - _event->next(NULL); -} - -bool -SocketInterface::process(Server::PostProcessor& dest, - Server::ProcessContext& context, - bool limit) -{ - if (_event) { - _event->execute(context); - dest.append(_event, _event); - _event = NULL; - } - return (_conn != -1); -} - SerdStatus SocketInterface::set_base_uri(SocketInterface* iface, const SerdNode* uri_node) @@ -118,8 +88,6 @@ SocketInterface::write_statement(SocketInterface* iface, void SocketInterface::_run() { - Thread::set_context(Server::THREAD_PRE_PROCESS); - Sord::World* world = _world.rdf_world(); LV2_URID_Map* map = &_world.lv2_uri_map()->urid_map_feature()->urid_map; @@ -206,14 +174,13 @@ SocketInterface::_run() } fclose(f); - sord_inserter_free(_inserter); serd_reader_end_stream(reader); sratom_free(sratom); serd_reader_free(reader); sord_free(model); - _conn = -1; + delete this; } } // namespace Ingen diff --git a/src/socket/SocketInterface.hpp b/src/socket/SocketInterface.hpp index b8d339f8..5e4daaf2 100644 --- a/src/socket/SocketInterface.hpp +++ b/src/socket/SocketInterface.hpp @@ -14,17 +14,10 @@ along with Ingen. If not, see <http://www.gnu.org/licenses/>. */ -#include <string> - #include "ingen/Interface.hpp" -#include "raul/SharedPtr.hpp" #include "raul/Thread.hpp" #include "sord/sord.h" -#include "../server/EventSink.hpp" -#include "../server/EventSource.hpp" -#include "../server/EventWriter.hpp" - namespace Ingen { namespace Shared { class World; } @@ -32,18 +25,9 @@ namespace Shared { class World; } namespace Socket { class SocketInterface : public Raul::Thread - , public Server::EventSink - , public Server::EventSource { public: - SocketInterface(Shared::World& world, int conn); - - void event(Server::Event* ev); - - bool process(Server::PostProcessor& dest, - Server::ProcessContext& context, - bool limit = true); - + SocketInterface(Shared::World& world, Interface& iface, int conn); ~SocketInterface(); SordInserter* inserter() { return _inserter; } @@ -67,13 +51,12 @@ private: const SerdNode* object_datatype, const SerdNode* object_lang); - Shared::World& _world; - Server::EventWriter _iface; - SerdEnv* _env; - SordInserter* _inserter; - SordNode* _msg_node; - Server::Event* _event; - int _conn; + Shared::World& _world; + Interface& _iface; + SerdEnv* _env; + SordInserter* _inserter; + SordNode* _msg_node; + int _conn; }; } // namespace Ingen diff --git a/src/socket/SocketListener.cpp b/src/socket/SocketListener.cpp index c2ff1c10..aeb50c5f 100644 --- a/src/socket/SocketListener.cpp +++ b/src/socket/SocketListener.cpp @@ -25,6 +25,7 @@ #include "sratom/sratom.h" #include "../server/Engine.hpp" +#include "../server/EventWriter.hpp" #include "SocketListener.hpp" #include "SocketInterface.hpp" @@ -36,6 +37,8 @@ namespace Socket { SocketListener::SocketListener(Ingen::Shared::World& world) : _world(world) { + set_name("SocketListener"); + // Create server socket _sock = socket(AF_UNIX, SOCK_STREAM, 0); if (_sock == -1) { @@ -91,8 +94,7 @@ SocketListener::_run() // Make an new interface/thread to handle the connection Server::Engine* engine = (Server::Engine*)_world.local_engine().get(); - SharedPtr<SocketInterface> iface(new SocketInterface(_world, conn)); - engine->add_event_source(iface); + new SocketInterface(_world, *engine->interface(), conn); } } diff --git a/src/socket/ingen_socket_server.cpp b/src/socket/ingen_socket_server.cpp index 71b8ad64..5bf679bb 100644 --- a/src/socket/ingen_socket_server.cpp +++ b/src/socket/ingen_socket_server.cpp @@ -21,7 +21,6 @@ #include "../server/Engine.hpp" #include "../server/EventWriter.hpp" -#include "../server/EventQueue.hpp" #include "SocketListener.hpp" |