18 #ifndef ION_REMOTE_HTTPSERVER_H_
19 #define ION_REMOTE_HTTPSERVER_H_
35 typedef std::map<std::string, std::string>
QueryMap;
38 class WebsocketHelper;
54 virtual int ReceiveData(
char* data,
size_t data_len,
bool is_binary) = 0;
58 void SendData(
const char* data,
size_t data_len,
bool is_binary);
61 void SetHelper(WebsocketHelper* helper) { helper_ = helper; }
62 friend class WebsocketHelper;
63 WebsocketHelper* helper_;
81 virtual const std::string HandleRequest(
const std::string& path,
83 std::string* content_type) = 0;
113 const std::string base_path_;
127 const std::string GetUriData(
const std::string& uri)
const;
130 bool IsRunning()
const;
136 void UnregisterHandler(
const std::string& path);
146 embed_local_sourced_files_ = embed;
150 size_t WebsocketCount();
166 friend class WebsocketHelper;
167 void RegisterWebsocket(
void* key, WebsocketHelper* helper);
168 void UnregisterWebsocket(
void* key);
169 WebsocketHelper* FindWebsocket(
void* key);
173 mg_context* context_;
186 bool embed_local_sourced_files_;
192 #endif // ION_REMOTE_HTTPSERVER_H_
const std::string & GetHeaderHtml() const
std::map< std::string, RequestHandlerPtr > HandlerMap
Represents the server side of a connected Websocket.
base::ReferentPtr< Websocket >::Type WebsocketPtr
Thread-safe abstract base class.
virtual void ConnectionReady()
Override to take some action when the connection is first established.
const std::string & GetBasePath() const
Returns the path this handler is registered at.
const std::string & GetFooterHtml() const
Sets/gets the header and footer HTML, which are both empty by default.
void SetFooterHtml(const std::string &str)
base::ReferentPtr< RequestHandler >::Type RequestHandlerPtr
void SetEmbedLocalSourcedFiles(bool embed)
bool EmbedLocalSourcedFiles() const
Gets, sets whether local sourced files (tags with src=...
virtual const WebsocketPtr ConnectWebsocket(const std::string &path, const QueryMap &args)
By default, RequestHandlers don't support websocket connections.
std::map< std::string, std::string > QueryMap
RequestHandlers handle requests for a file or path.
A SharedPtr is a smart shared pointer to an instance of some class that implements reference counting...
A Mutex is used to ensure that only one thread or process can access a block of code at one time...
void SetHeaderHtml(const std::string &str)
std::map< void *, WebsocketHelper * > WebsocketMap