summaryrefslogtreecommitdiffstats
path: root/src/server
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-05-10 02:14:55 +0000
committerDavid Robillard <d@drobilla.net>2012-05-10 02:14:55 +0000
commit281bbcc6a7208c28283bc9bdd521c5d6cc48a60f (patch)
tree6cfc2bf6c3c0d92b3cb5a79a4d019d5952d41989 /src/server
parentcd2ac251d7e076e3bf25f2640d1684447efa83d3 (diff)
downloadingen-281bbcc6a7208c28283bc9bdd521c5d6cc48a60f.tar.gz
ingen-281bbcc6a7208c28283bc9bdd521c5d6cc48a60f.tar.bz2
ingen-281bbcc6a7208c28283bc9bdd521c5d6cc48a60f.zip
Bidirectional socket communication (GUI once again works remotely).
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4335 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/server')
-rw-r--r--src/server/ClientBroadcaster.cpp10
-rw-r--r--src/server/EventWriter.cpp88
-rw-r--r--src/server/EventWriter.hpp12
-rw-r--r--src/server/ingen_lv2.cpp2
4 files changed, 50 insertions, 62 deletions
diff --git a/src/server/ClientBroadcaster.cpp b/src/server/ClientBroadcaster.cpp
index e44475b1..46e6fb2f 100644
--- a/src/server/ClientBroadcaster.cpp
+++ b/src/server/ClientBroadcaster.cpp
@@ -39,14 +39,8 @@ void
ClientBroadcaster::register_client(const URI& uri, Interface* client)
{
Glib::Mutex::Lock lock(_clients_mutex);
- Clients::iterator i = _clients.find(uri);
-
- if (i == _clients.end()) {
- _clients[uri] = client;
- LOG(info) << "Registered client: " << uri << endl;
- } else {
- LOG(warn) << "Client already registered: " << uri << endl;
- }
+ LOG(info) << "Registered client: " << uri << endl;
+ _clients[uri] = client;
}
/** Remove a client from the list of registered clients.
diff --git a/src/server/EventWriter.cpp b/src/server/EventWriter.cpp
index ca8ad196..19a738b0 100644
--- a/src/server/EventWriter.cpp
+++ b/src/server/EventWriter.cpp
@@ -35,10 +35,9 @@ namespace Ingen {
namespace Server {
EventWriter::EventWriter(Engine& engine)
- : _request_client(NULL)
+ : _engine(engine)
+ , _respondee(NULL)
, _request_id(-1)
- , _engine(engine)
- , _in_bundle(false)
{
}
@@ -49,48 +48,32 @@ EventWriter::~EventWriter()
SampleCount
EventWriter::now() const
{
- // Exactly one cycle latency (some could run ASAP if we get lucky, but not always, and a slight
- // constant latency is far better than jittery lower (average) latency
- if (_engine.driver())
- return _engine.driver()->frame_time() + _engine.driver()->block_length();
- else
- return 0;
+ /* Exactly one cycle latency (some could run ASAP if we get lucky, but not
+ always, and a slight constant latency is far better than jittery lower
+ (average) latency */
+ return (_engine.driver())
+ ? _engine.driver()->frame_time() + _engine.driver()->block_length()
+ : 0;
}
void
EventWriter::set_response_id(int32_t id)
{
- if (!_request_client) { // Kludge
- _request_client = _engine.broadcaster()->client(
+ if (!_respondee) { // Kludge
+ _respondee = _engine.broadcaster()->client(
"http://drobilla.net/ns/ingen#internal");
}
_request_id = id;
}
-/* *** ServerInterface implementation below here *** */
-
-// Bundle commands
-
-void
-EventWriter::bundle_begin()
-{
- _in_bundle = true;
-}
-
-void
-EventWriter::bundle_end()
-{
- _in_bundle = false;
-}
-
-// Object commands
-
void
EventWriter::put(const URI& uri,
const Resource::Properties& properties,
const Resource::Graph ctx)
{
- _engine.enqueue_event(new Events::SetMetadata(_engine, _request_client, _request_id, now(), true, ctx, uri, properties));
+ _engine.enqueue_event(
+ new Events::SetMetadata(_engine, _respondee, _request_id, now(),
+ true, ctx, uri, properties));
}
void
@@ -98,26 +81,31 @@ EventWriter::delta(const URI& uri,
const Resource::Properties& remove,
const Resource::Properties& add)
{
- _engine.enqueue_event(new Events::SetMetadata(_engine, _request_client, _request_id, now(), false, Resource::DEFAULT, uri, add, remove));
+ _engine.enqueue_event(
+ new Events::SetMetadata(_engine, _respondee, _request_id, now(),
+ false, Resource::DEFAULT, uri, add, remove));
}
void
EventWriter::move(const Path& old_path,
const Path& new_path)
{
- _engine.enqueue_event(new Events::Move(_engine, _request_client, _request_id, now(), old_path, new_path));
+ _engine.enqueue_event(
+ new Events::Move(_engine, _respondee, _request_id, now(),
+ old_path, new_path));
}
void
EventWriter::del(const URI& uri)
{
if (uri == "ingen:engine") {
- if (_request_client) {
- _request_client->response(_request_id, SUCCESS);
+ if (_respondee) {
+ _respondee->response(_request_id, SUCCESS);
}
_engine.quit();
} else {
- _engine.enqueue_event(new Events::Delete(_engine, _request_client, _request_id, now(), uri));
+ _engine.enqueue_event(
+ new Events::Delete(_engine, _respondee, _request_id, now(), uri));
}
}
@@ -125,7 +113,9 @@ void
EventWriter::connect(const Path& tail_path,
const Path& head_path)
{
- _engine.enqueue_event(new Events::Connect(_engine, _request_client, _request_id, now(), tail_path, head_path));
+ _engine.enqueue_event(
+ new Events::Connect(_engine, _respondee, _request_id, now(),
+ tail_path, head_path));
}
@@ -139,15 +129,18 @@ EventWriter::disconnect(const Path& src,
return;
}
- _engine.enqueue_event(new Events::Disconnect(_engine, _request_client, _request_id, now(),
- Path(src.str()), Path(dst.str())));
+ _engine.enqueue_event(
+ new Events::Disconnect(_engine, _respondee, _request_id, now(),
+ src, dst));
}
void
EventWriter::disconnect_all(const Path& patch_path,
const Path& path)
{
- _engine.enqueue_event(new Events::DisconnectAll(_engine, _request_client, _request_id, now(), patch_path, path));
+ _engine.enqueue_event(
+ new Events::DisconnectAll(_engine, _respondee, _request_id, now(),
+ patch_path, path));
}
void
@@ -159,27 +152,28 @@ EventWriter::set_property(const URI& uri,
&& value.type() == _engine.world()->forge().Bool) {
if (value.get_bool()) {
_engine.activate();
- _engine.enqueue_event(new Events::Ping(_engine, _request_client, _request_id, now()));
+ _engine.enqueue_event(
+ new Events::Ping(_engine, _respondee, _request_id, now()));
} else {
- _engine.enqueue_event(new Events::Deactivate(_engine, _request_client, _request_id, now()));
+ _engine.enqueue_event(
+ new Events::Deactivate(_engine, _respondee, _request_id, now()));
}
} else {
Resource::Properties remove;
remove.insert(make_pair(predicate, _engine.world()->uris()->wildcard));
Resource::Properties add;
add.insert(make_pair(predicate, value));
- _engine.enqueue_event(new Events::SetMetadata(
- _engine, _request_client, _request_id, now(), false, Resource::DEFAULT,
- uri, add, remove));
+ _engine.enqueue_event(
+ new Events::SetMetadata(_engine, _respondee, _request_id, now(),
+ false, Resource::DEFAULT, uri, add, remove));
}
}
-// Requests //
-
void
EventWriter::get(const URI& uri)
{
- _engine.enqueue_event(new Events::Get(_engine, _request_client, _request_id, now(), uri));
+ _engine.enqueue_event(
+ new Events::Get(_engine, _respondee, _request_id, now(), uri));
}
} // namespace Server
diff --git a/src/server/EventWriter.hpp b/src/server/EventWriter.hpp
index 1c5d11db..9e334f98 100644
--- a/src/server/EventWriter.hpp
+++ b/src/server/EventWriter.hpp
@@ -42,13 +42,13 @@ public:
Raul::URI uri() const { return "http://drobilla.net/ns/ingen#internal"; }
- void set_response_interface(Interface* iface) { _request_client = iface; }
+ void set_respondee(Interface* iface) { _respondee = iface; }
virtual void set_response_id(int32_t id);
- virtual void bundle_begin();
+ virtual void bundle_begin() {}
- virtual void bundle_end();
+ virtual void bundle_end() {}
virtual void put(const Raul::URI& path,
const Resource::Properties& properties,
@@ -79,13 +79,13 @@ public:
virtual void get(const Raul::URI& uri);
virtual void response(int32_t id, Status status) {} ///< N/A
+
virtual void error(const std::string& msg) {} ///< N/A
protected:
- Interface* _request_client;
- int32_t _request_id;
Engine& _engine;
- bool _in_bundle; ///< True iff a bundle is currently being received
+ Interface* _respondee;
+ int32_t _request_id;
private:
SampleCount now() const;
diff --git a/src/server/ingen_lv2.cpp b/src/server/ingen_lv2.cpp
index 5e418485..733f7a52 100644
--- a/src/server/ingen_lv2.cpp
+++ b/src/server/ingen_lv2.cpp
@@ -438,7 +438,7 @@ ingen_instantiate(const LV2_Descriptor* descriptor,
LV2Driver* driver = new LV2Driver(*engine.get(), 4096, rate);
engine->set_driver(SharedPtr<Ingen::Server::Driver>(driver));
- interface->set_response_interface(&driver->writer());
+ interface->set_respondee(&driver->writer());
engine->register_client("http://drobilla.net/ns/ingen#internal",
&driver->writer());