summaryrefslogtreecommitdiffstats
path: root/src/client
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2008-11-15 22:56:24 +0000
committerDavid Robillard <d@drobilla.net>2008-11-15 22:56:24 +0000
commitfb6471ac9d5daefd3655bc19532a6028b5f0ead4 (patch)
treebec99ab0a594e3be390b393af63064ce4a26f57f /src/client
parent6f0b9a0c5a21bb660363d417313add2f66447255 (diff)
downloadingen-fb6471ac9d5daefd3655bc19532a6028b5f0ead4.tar.gz
ingen-fb6471ac9d5daefd3655bc19532a6028b5f0ead4.tar.bz2
ingen-fb6471ac9d5daefd3655bc19532a6028b5f0ead4.zip
Stubs for HTTP streaming.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@1719 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/client')
-rw-r--r--src/client/HTTPClientReceiver.cpp48
-rw-r--r--src/client/HTTPClientReceiver.hpp17
2 files changed, 59 insertions, 6 deletions
diff --git a/src/client/HTTPClientReceiver.cpp b/src/client/HTTPClientReceiver.cpp
index 624a7786..9116f853 100644
--- a/src/client/HTTPClientReceiver.cpp
+++ b/src/client/HTTPClientReceiver.cpp
@@ -50,10 +50,41 @@ HTTPClientReceiver::~HTTPClientReceiver()
void
+HTTPClientReceiver::Listener::_run()
+{
+#if 0
+ cout << "LISTENER RUN" << endl;
+ /*const string uri = "http://localhost:16180";
+ SoupMessage* msg = soup_message_new("GET", (uri + "/stream").c_str());
+ soup_message_headers_set_encoding(msg->response_headers, SOUP_ENCODING_CHUNKED);
+ soup_session_send_message(_session, msg);*/
+
+ size_t offset = 0;
+ soup_message_body_set_accumulate(_msg->response_body, false);
+ while (true) {
+ SoupBuffer* chunk = soup_message_body_get_chunk(_msg->response_body, offset);
+ if (chunk == NULL) {
+ //cout << "WAITING FOR DATA" << endl;
+ } else if (chunk->length == 0) {
+ cout << "CHUNKED TRANSFER COMPLETED" << endl;
+ break;
+ } else {
+ cout << "RECEIVED CHUNK: " << (char*)chunk->data << endl;
+ offset += chunk->length;
+ }
+ }
+
+ cout << "LISTENER FINISHED" << endl;
+#endif
+}
+
+
+void
HTTPClientReceiver::message_callback(SoupSession* session, SoupMessage* msg, void* ptr)
{
HTTPClientReceiver* me = (HTTPClientReceiver*)ptr;
const string path = soup_message_get_uri(msg)->path;
+ cout << "MESSAGE: " << path << endl;
if (path == "/") {
me->_target->response_ok(0);
me->_target->enable();
@@ -77,6 +108,12 @@ HTTPClientReceiver::message_callback(SoupSession* session, SoupMessage* msg, voi
Glib::ustring(msg->response_body->data),
Glib::ustring("/patch/"), Glib::ustring(""));
}
+ } else if (path == "/stream") {
+ cout << "STREAM" << endl;
+ //me->_listener = boost::shared_ptr<Listener>(new Listener(me->_session, msg));
+ //me->_listener->start();
+ } else {
+ cerr << "UNKNOWN MESSAGE: " << path << endl;
}
}
@@ -96,17 +133,20 @@ HTTPClientReceiver::start(bool dump)
}
}
- _session = soup_session_async_new();
+ _session = soup_session_sync_new();
SoupMessage* msg;
msg = soup_message_new("GET", _url.c_str());
- soup_session_queue_message (_session, msg, message_callback, this);
+ soup_session_queue_message(_session, msg, message_callback, this);
msg = soup_message_new("GET", (_url + "/plugins").c_str());
- soup_session_queue_message (_session, msg, message_callback, this);
+ soup_session_queue_message(_session, msg, message_callback, this);
msg = soup_message_new("GET", (_url + "/patch").c_str());
- soup_session_queue_message (_session, msg, message_callback, this);
+ soup_session_queue_message(_session, msg, message_callback, this);
+
+ msg = soup_message_new("GET", (_url + "/stream").c_str());
+ soup_session_queue_message(_session, msg, message_callback, this);
}
diff --git a/src/client/HTTPClientReceiver.hpp b/src/client/HTTPClientReceiver.hpp
index bab55578..379ffe2d 100644
--- a/src/client/HTTPClientReceiver.hpp
+++ b/src/client/HTTPClientReceiver.hpp
@@ -21,10 +21,11 @@
#include <cstdlib>
#include <boost/utility.hpp>
#include <libsoup/soup.h>
-#include "interface/ClientInterface.hpp"
-#include "serialisation/Parser.hpp"
#include "redlandmm/World.hpp"
#include "raul/Deletable.hpp"
+#include "raul/Thread.hpp"
+#include "interface/ClientInterface.hpp"
+#include "serialisation/Parser.hpp"
namespace Ingen {
namespace Client {
@@ -46,7 +47,19 @@ public:
private:
static void message_callback(SoupSession* session, SoupMessage* msg, void* ptr);
+
+ class Listener : public Raul::Thread {
+ public:
+ Listener(SoupSession* session, SoupMessage* msg) : _session(session), _msg(msg) {}
+ void _run();
+ private:
+ SoupSession* _session;
+ SoupMessage* _msg;
+ };
+ friend class Listener;
+ SharedPtr<Listener> _listener;
+
SharedPtr<Shared::ClientInterface> _target;
Shared::World* _world;