blob: d3b0c48a7040e2d3201eff2d8a67c7cd26346c8d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
#ifndef MMISESSIONMANAGER_H_IHDWUAKD
#define MMISESSIONMANAGER_H_IHDWUAKD
#include <uscxml/Interpreter.h>
#include <deque>
#include "../MMIEventServlet.h"
namespace uscxml {
class MMISessionManager : public HTTPServlet {
public:
MMISessionManager(Interpreter interpreter);
~MMISessionManager();
class MMISession {
public:
Interpreter _interpreter;
tthread::recursive_mutex _mutex;
virtual void send(const SendRequest& req) = 0;
virtual void receive(const Arabica::DOM::Node<std::string>& msg) = 0;
};
class CometMMISession : public MMISession {
public:
std::deque<SendRequest> _outQueue;
HTTPServer::Request _longPollingReq;
std::string _token;
void send(const SendRequest& req);
void receive(const Arabica::DOM::Node<std::string>& msg);
void longPoll(const HTTPServer::Request& req);
};
class MMIIOProcessor : public IOProcessorImpl {
public:
MMIIOProcessor(MMISessionManager* sessionManager) : _sessionManager(sessionManager) {}
// IOProcessorImpl
virtual boost::shared_ptr<IOProcessorImpl> create(InterpreterImpl* interpreter);
virtual std::set<std::string> getNames() {
std::set<std::string> names;
names.insert("mmi.event");
return names;
}
virtual Data getDataModelVariables();
virtual void send(const SendRequest& req);
protected:
MMISessionManager* _sessionManager;
};
void send(const std::string& name, const SendRequest& req);
/// HTTPServlet
bool httpRecvRequest(const HTTPServer::Request& req);
void setURL(const std::string& url) {
_url = url;
}
std::string getURL() { return _url; }
bool canAdaptPath() {
return false;
}
protected:
void received(const NewContextRequest& mmiEvent, const std::string& token = "");
void received(const NewContextResponse& mmiEvent, const std::string& token = "");
void received(const ExtensionNotification& mmiEvent);
void received(const DoneNotification& mmiEvent);
void setupHTMLClient(const HTTPServer::Request& req);
Interpreter _protoInterpreter;
Factory* _factory;
DelayedEventQueue _eventQueue;
std::map<std::string, MMISession*> _sessions;
std::map<std::string, MMISession*> _tokens;
std::string _url;
};
}
#endif /* end of include guard: MMISESSIONMANAGER_H_IHDWUAKD */
|