#ifndef WEBFUSE_SERVER_HANDLER_HPP #define WEBFUSE_SERVER_HANDLER_HPP #include "webfuse/ws/messagereader.hpp" #include "webfuse/ws/messagewriter.hpp" #include #include #include #include #include #include #include namespace webfuse { class server_handler { public: server_handler(std::string const & auth_app, std::string const & auth_hdr); int filter_connection(lws * wsi); int on_established(lws* wsi); void on_receive(lws * wsi, void* in, int len); int on_writable(); void on_closed(lws * wsi); std::future perform(messagewriter writer); void poll(); private: int authenticate_via_header(lws * wsi); std::string get_auth_token(lws * wsi) const; uint32_t next_id(); void finish_authentication(lws * wsi, messagereader reader); struct lws * connection; uint32_t id; bool shutdown_requested; std::atomic is_authenticated; std::string authenticator; std::string auth_header; std::string current_message; std::mutex mut; std::queue requests; std::unordered_map> pending_responses; }; } #endif