diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-03-22 23:35:31 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-03-22 23:35:31 (GMT) |
commit | e9bd7e313c80ccdabc52757266177363c7638caf (patch) | |
tree | 4b048b5d8d88d8f630291c6a1c6991369e6ce727 /src/uscxml/server | |
parent | c7f8f82d632f3d205ef6de6377115ea0f7536302 (diff) | |
download | uscxml-e9bd7e313c80ccdabc52757266177363c7638caf.zip uscxml-e9bd7e313c80ccdabc52757266177363c7638caf.tar.gz uscxml-e9bd7e313c80ccdabc52757266177363c7638caf.tar.bz2 |
Fixed plugins building again
Diffstat (limited to 'src/uscxml/server')
-rw-r--r-- | src/uscxml/server/InterpreterServlet.cpp | 34 | ||||
-rw-r--r-- | src/uscxml/server/InterpreterServlet.h | 46 |
2 files changed, 80 insertions, 0 deletions
diff --git a/src/uscxml/server/InterpreterServlet.cpp b/src/uscxml/server/InterpreterServlet.cpp new file mode 100644 index 0000000..fb8a6ef --- /dev/null +++ b/src/uscxml/server/InterpreterServlet.cpp @@ -0,0 +1,34 @@ +#include "InterpreterServlet.h" +#include "uscxml/Interpreter.h" + +namespace uscxml { + +InterpreterServlet::InterpreterServlet(Interpreter* interpreter) { + _interpreter = interpreter; + + std::stringstream path; + path << _interpreter->getName(); + int i = 2; + while(!HTTPServer::registerServlet(path.str(), this)) { + path.clear(); + path.str(); + path << _interpreter->getName() << i++; + } + _path = path.str(); +} + +void InterpreterServlet::httpRecvRequest(const HTTPServer::Request& req) { + tthread::lock_guard<tthread::recursive_mutex> lock(_mutex); + + // evhttp_request_own(req.curlReq); + + _requests[toStr((uintptr_t)req.curlReq)] = req; + + Event event = req; + + event.name = "http." + event.data.compound["type"].atom; + event.origin = toStr((uintptr_t)req.curlReq); + _interpreter->receive(event); +} + +}
\ No newline at end of file diff --git a/src/uscxml/server/InterpreterServlet.h b/src/uscxml/server/InterpreterServlet.h new file mode 100644 index 0000000..7235466 --- /dev/null +++ b/src/uscxml/server/InterpreterServlet.h @@ -0,0 +1,46 @@ +#ifndef INTERPRETERSERVLET_H_XQLWNMH4 +#define INTERPRETERSERVLET_H_XQLWNMH4 + +#include "HTTPServer.h" + +namespace uscxml { + +class Interpreter; + +class InterpreterServlet : public HTTPServlet { +public: + InterpreterServlet(Interpreter* interpreter); + virtual void httpRecvRequest(const HTTPServer::Request& req); + + std::string getPath() { + return _path; + } + std::string getURL() { + return _url; + } + void setURL(const std::string& url) { + _url = url; + } + bool canAdaptPath() { return false; } + + std::map<std::string, HTTPServer::Request>& getRequests() { + return _requests; + } + tthread::recursive_mutex& getMutex() { + return _mutex; + } + +protected: + Interpreter* _interpreter; + + tthread::recursive_mutex _mutex; + std::map<std::string, HTTPServer::Request> _requests; + std::string _path; + std::string _url; + +}; + +} + + +#endif /* end of include guard: INTERPRETERSERVLET_H_XQLWNMH4 */ |