#pragma once #include "../../common/adc_traits.h" #include namespace adc::impl { template > // used only for inner storing of message byte sequence class AdcNetServiceUWS { public: // typedefs to satisfy 'adc_netservice_c' concept typedef std::string_view netservice_ident_t; typedef std::vector send_msg_t; // in general, only one of several possible typedef RMSGT recv_msg_t; // in general, only one of several possible (see class template arguments declaration) typedef traits::adc_common_duration_t timeout_t; typedef std::pair endpoint_t; // {host, port} // typedefs for completion tokens (callbacks, required by 'adc_netservice_c' concept) typedef std::function async_connect_callback_t; typedef std::function async_send_callback_t; typedef std::function async_receive_callback_t; class acceptor_t { public: static constexpr std::chrono::duration DEFAULT_ACCEPT_TIMEOUT = std::chrono::seconds::max(); acceptor_t(uWS::SSLApp& app, const AdcNetServiceUWS::endpoint_t& endpoint) : _uwsApp(app), _endpoint(endpoint) { } typedef AdcNetServiceUWS netservice_t; typedef std::shared_ptr sptr_netservice_t; typedef std::function async_accept_callback_t; template TokenT> auto asyncAccept(TokenT&& token, const traits::adc_time_duration_c auto& timeout = DEFAULT_ACCEPT_TIMEOUT) { // just call listen method _uwsApp.listen(_endpoint.first, _endpoint.second, [wrapper = traits::adc_pf_wrapper(std::forward(token)), this](auto* sock) { std::error_code ec; if (!sock) { std::get<0>(wrapper)(std::make_error_code(std::errc::not_connected), std::make_shared(_uwsApp)); } }); } template auto accept(const DT& timeout = DEFAULT_ACCEPT_TIMEOUT) { } private: uWS::SSLApp& _uwsApp; AdcNetServiceUWS::endpoint_t _endpoint; }; AdcNetServiceUWS(uWS::SSLApp& app) {} }; } // namespace adc::impl