diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-01-25 01:41:49 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-01-25 01:41:49 (GMT) |
commit | 32921490d0d7dc0a2e0828e6f1051e74d27550cf (patch) | |
tree | fe0a816013ddfb2c4d8b2fa885a6b56c61e670f8 /src/uscxml/plugins | |
parent | 3be96d1aa3024c1acc129e587f5d3165c9434e48 (diff) | |
download | uscxml-32921490d0d7dc0a2e0828e6f1051e74d27550cf.zip uscxml-32921490d0d7dc0a2e0828e6f1051e74d27550cf.tar.gz uscxml-32921490d0d7dc0a2e0828e6f1051e74d27550cf.tar.bz2 |
Started to resolve scxml-test-framework tests from SCION suite
Diffstat (limited to 'src/uscxml/plugins')
-rw-r--r-- | src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.cpp | 16 | ||||
-rw-r--r-- | src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.h | 21 |
2 files changed, 23 insertions, 14 deletions
diff --git a/src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.cpp b/src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.cpp index b051310..3ed39d6 100644 --- a/src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.cpp +++ b/src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.cpp @@ -112,7 +112,7 @@ void EventIOProcessor::send(const SendRequest& req) { _httpConnections[endPoint] = evhttp_connection_base_new(_asyncQueue._eventLoop, _dns, evhttp_uri_get_host(targetURI), evhttp_uri_get_port(targetURI)); struct evhttp_connection* httpConn = _httpConnections[endPoint]; - struct evhttp_request* httpReq = evhttp_request_new(EventIOProcessor::httpSendReqDone, this); + struct evhttp_request* httpReq = evhttp_request_new(EventIOServer::httpSendReqDoneCallback, this); // event name if (req.name.size() > 0) { @@ -163,7 +163,7 @@ void EventIOProcessor::send(const SendRequest& req) { } } -void EventIOProcessor::httpRecvReq(struct evhttp_request *req, void *arg) { +void EventIOProcessor::httpRecvReq(struct evhttp_request *req) { const char *cmdtype; struct evkeyvalq *headers; @@ -242,13 +242,11 @@ void EventIOProcessor::httpRecvReq(struct evhttp_request *req, void *arg) { reqEvent.compound["content"] = Data(content, Data::VERBATIM); } - EventIOProcessor* INSTANCE = (EventIOProcessor*)arg; - INSTANCE->returnEvent(reqEvent); - + returnEvent(reqEvent); evhttp_send_reply(req, 200, "OK", NULL); } -void EventIOProcessor::httpSendReqDone(struct evhttp_request *req, void *cb_arg) { +void EventIOProcessor::httpSendReqDone(struct evhttp_request *req) { if (req) { LOG(INFO) << "got return code " << evhttp_request_get_response_code(req) << std::endl; } @@ -294,7 +292,7 @@ void EventIOServer::registerProcessor(EventIOProcessor* processor) { * If the interpreter does not specify a name, take its sessionid. */ - std::string path = processor->_interpreter->getName(); + std::string path = processor->getPath(); if (path.size() == 0) { path = processor->_interpreter->getSessionId(); } @@ -316,7 +314,8 @@ void EventIOServer::registerProcessor(EventIOProcessor* processor) { LOG(INFO) << "SCXML listening at: " << processorURL.str() << std::endl; - evhttp_set_cb(INSTANCE->_http, ("/" + actualPath.str()).c_str(), EventIOProcessor::httpRecvReq, processor); + evhttp_set_cb(INSTANCE->_http, ("/" + actualPath.str()).c_str(), EventIOServer::httpRecvReqCallback, processor); + // evhttp_set_cb(THIS->_http, "/", EventIOProcessor::httpRecvReq, processor); // evhttp_set_gencb(THIS->_http, EventIOProcessor::httpRecvReq, NULL); } @@ -334,6 +333,7 @@ void EventIOServer::start() { void EventIOServer::run(void* instance) { EventIOServer* INSTANCE = (EventIOServer*)instance; + LOG(INFO) << "HTTP Server started" << std::endl; while(INSTANCE->_isRunning) { event_base_dispatch(INSTANCE->_base); } diff --git a/src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.h b/src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.h index 3afe463..783332e 100644 --- a/src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.h +++ b/src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.h @@ -47,9 +47,9 @@ public: void start(); static void run(void* instance); - static void httpMakeSendReq(void* userdata, std::string eventName); - static void httpSendReqDone(struct evhttp_request *req, void *cb_arg); - static void httpRecvReq(struct evhttp_request *req, void *arg); + virtual std::string getPath() { return _interpreter->getName(); } + virtual void httpSendReqDone(struct evhttp_request *req); + virtual void httpRecvReq(struct evhttp_request *req); protected: std::map<std::string, SendData> _sendData; @@ -65,8 +65,13 @@ protected: }; class EventIOServer { +public: + static EventIOServer* getInstance(); + + static void registerProcessor(EventIOProcessor* processor); + static void unregisterProcessor(EventIOProcessor* processor); + private: - static EventIOServer* getInstance(); EventIOServer(unsigned short port); ~EventIOServer(); @@ -77,9 +82,13 @@ private: void determineAddress(); static std::string syncResolve(const std::string& hostname); - static void registerProcessor(EventIOProcessor* processor); - static void unregisterProcessor(EventIOProcessor* processor); + static void httpSendReqDoneCallback(struct evhttp_request *req, void *cb_arg) { + ((EventIOProcessor*)cb_arg)->httpSendReqDone(req); + } + static void httpRecvReqCallback(struct evhttp_request *req, void *cb_arg) { + ((EventIOProcessor*)cb_arg)->httpRecvReq(req); + } std::map<std::string, EventIOProcessor*> _processors; |