diff options
Diffstat (limited to 'tests/websocketserverprocess.h')
-rw-r--r-- | tests/websocketserverprocess.h | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/websocketserverprocess.h b/tests/websocketserverprocess.h new file mode 100644 index 0000000..74d7064 --- /dev/null +++ b/tests/websocketserverprocess.h @@ -0,0 +1,53 @@ +#pragma once + +#include <boost/algorithm/string.hpp> +#include <boost/beast/core.hpp> +#include <boost/beast/http.hpp> +#include <boost/beast/websocket.hpp> +#include <boost/beast/websocket/ssl.hpp> +#include <boost/beast/ssl.hpp> +#include <boost/beast/version.hpp> +#include <boost/asio/buffer.hpp> +#include <boost/asio/buffers_iterator.hpp> +#include <boost/asio/connect.hpp> +#include <boost/asio/ip/tcp.hpp> +#include <boost/asio/ssl/error.hpp> +#include <boost/asio/ssl/stream.hpp> +#include <boost/property_tree/ptree.hpp> +#include <boost/property_tree/xml_parser.hpp> + +#include <functional> +#include <memory> +#include <mutex> +#include <string> + +class WebsocketServerProcess +{ + // shared data between Unix processes + struct shared_data_t { + std::mutex mutex; // for synchronization between processes (!) + char subprotocol[1024]{}; // instead of std::string since std::string allocates data on heap + char target[1024]{}; + }; + +public: + WebsocketServerProcess(); + ~WebsocketServerProcess(); + + bool is_running(); + void start(); + void stop(); + std::string subprotocol(); + std::string target(); + +private: + void do_session(boost::asio::ip::tcp::socket socket); + +private: + int m_pid{}; + int m_count{}; + std::unique_ptr<shared_data_t, std::function<void(shared_data_t*)>> m_shared; +}; // class WebsocketServerProcess + + + |