summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2012-03-30 11:37:58 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2012-03-30 11:37:58 +0200
commit39e9508260335eb5cd817e9899a11cb011efdbed (patch)
treefe3b9c6dde89be8d77a324e802e67de5d1b32b88 /src
parent91dad205b83319e00ea8060ca5a63de07b126c8f (diff)
Add observe protocol and connection handler.
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am10
-rw-r--r--src/connectionhandler.cc5
-rw-r--r--src/connectionhandler.h3
-rw-r--r--src/muniad.cc23
-rw-r--r--src/task_proto.cc2
-rw-r--r--src/xmlparser.h3
6 files changed, 25 insertions, 21 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 8c2cc25..781422d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -7,25 +7,29 @@ muniad_LDADD = $(LIBWEBSOCKETS_LIBS) $(EXPAT_LIBS)
muniad_CXXFLAGS = $(LIBWEBSOCKETS_CFLAGS) $(EXPAT_CFLAGS) -I/usr/local/include
muniad_SOURCES = \
- debug.cc \
muniad.cc \
+ connectionhandler.cc \
+ debug.cc \
log.cc \
http.cc \
- msgparser.cc \
+ messageparser.cc \
saxparser.cc \
task.cc \
task_proto.cc \
+ observe_proto.cc \
xml_encode_decode.cc \
xmlparser.cc
EXTRA_DIST = \
debug.h \
+ connectionhandler.h \
log.h \
http.h \
- msgparser.h \
+ messageparser.h \
saxparser.h \
task.h \
task_proto.h \
+ observe_proto.h \
xml_encode_decode.h \
xmlparser.h
diff --git a/src/connectionhandler.cc b/src/connectionhandler.cc
index 61738e2..6fdcd51 100644
--- a/src/connectionhandler.cc
+++ b/src/connectionhandler.cc
@@ -27,6 +27,9 @@
*/
#include "connectionhandler.h"
+// Global ConnectionHandler.
+ConnectionHandler connection_handler;
+
ConnectionHandler::ConnectionHandler()
{
}
@@ -77,7 +80,7 @@ std::set<clientid_t> ConnectionHandler::observerlist(TaskIdList tasks)
TEST_BEGIN;
-ConnectionHandler h;
+ConnectionHandler &h = connection_handler;
h.init((clientid_t)1);
h.observe((clientid_t)1, (taskid_t)1);
diff --git a/src/connectionhandler.h b/src/connectionhandler.h
index ab46320..9aba0cb 100644
--- a/src/connectionhandler.h
+++ b/src/connectionhandler.h
@@ -53,4 +53,7 @@ private:
ConnectionList connlist;
};
+// Global ConnectionHandler
+extern ConnectionHandler connection_handler;
+
#endif/*__MUNIA_CONNECTIONHANDLER_H__*/
diff --git a/src/muniad.cc b/src/muniad.cc
index 4523d8a..a414462 100644
--- a/src/muniad.cc
+++ b/src/muniad.cc
@@ -37,25 +37,18 @@
#include "http.h"
#include "task_proto.h"
-
-/* list of supported protocols and callbacks */
+#include "observe_proto.h"
static struct libwebsocket_protocols protocols[] = {
- /* first protocol must always be HTTP handler */
-
- {
- "http-only", /* name */
- callback_http, /* callback */
- 0 /* per_session_data_size */
+ // first protocol must always be HTTP handler
+ { "http-only", callback_http, 0 },
+ { "lws-task-protocol", callback_lws_task,
+ sizeof(struct per_session_data__lws_task)
},
- {
- "lws-task-protocol",
- callback_lws_task,
- sizeof(struct per_session_data__lws_task)
+ { "lws-observe-protocol", callback_lws_observe,
+ sizeof(struct per_session_data__lws_observe)
},
- {
- NULL, NULL, 0 /* End of list */
- }
+ { NULL, NULL, 0 } // End of list
};
static struct option options[] = {
diff --git a/src/task_proto.cc b/src/task_proto.cc
index d273344..6a4e762 100644
--- a/src/task_proto.cc
+++ b/src/task_proto.cc
@@ -34,7 +34,7 @@
#include <map>
#include "task.h"
-#include "msgparser.h"
+#include "messageparser.h"
#include "xmlparser.h"
static void dump_handshake_info(struct lws_tokens *lwst)
diff --git a/src/xmlparser.h b/src/xmlparser.h
index 85a0600..a92a515 100644
--- a/src/xmlparser.h
+++ b/src/xmlparser.h
@@ -40,7 +40,8 @@ public:
void endTag(std::string name);
void characterData(std::string& data);
- TaskList tasklist;
+ TaskIdList tasklist;
+
protected:
int readData(char* data, size_t size);