This commit is contained in:
Timur A. Fatkhullin 2024-10-17 18:03:47 +03:00
parent cbc69bb9ce
commit 672788d59d
2 changed files with 10 additions and 4 deletions

View File

@ -267,6 +267,7 @@ public:
std::function<void(SocketT*)> onOpen; std::function<void(SocketT*)> onOpen;
std::function<void(SocketT*, std::error_code)> onClose; std::function<void(SocketT*, std::error_code)> onClose;
std::function<void(SocketT*, std::span<const char>)> onData; std::function<void(SocketT*, std::span<const char>)> onData;
std::function<void(SocketT*, std::error_code)> onError;
}; };
@ -277,6 +278,8 @@ public:
{ {
} }
void stop() {}
protected: protected:
ServerControls _serverControls; ServerControls _serverControls;
}; };

View File

@ -43,10 +43,7 @@ public:
template <std::convertible_to<async_accept_callback_t> TokenT> template <std::convertible_to<async_accept_callback_t> TokenT>
auto asyncAccept(TokenT&& token, const traits::adc_time_duration_c auto& timeout = DEFAULT_ACCEPT_TIMEOUT) auto asyncAccept(TokenT&& token, const traits::adc_time_duration_c auto& timeout = DEFAULT_ACCEPT_TIMEOUT)
{ {
_uwsApp.ws("/*", {.open = [wrapper = traits::adc_pf_wrapper(std::forward<TokenT>(token)), this](auto) { // just call listen method
std::get<0>(wrapper)(std::error_code{}, std::make_shared<AdcNetServiceUWS>(_uwsApp));
}});
_uwsApp.listen(_endpoint.first, _endpoint.second, _uwsApp.listen(_endpoint.first, _endpoint.second,
[wrapper = traits::adc_pf_wrapper(std::forward<TokenT>(token)), this](auto* sock) { [wrapper = traits::adc_pf_wrapper(std::forward<TokenT>(token)), this](auto* sock) {
std::error_code ec; std::error_code ec;
@ -57,6 +54,12 @@ public:
}); });
} }
template <traits::adc_time_duration_c DT = decltype(DEFAULT_ACCEPT_TIMEOUT)>
auto accept(const DT& timeout = DEFAULT_ACCEPT_TIMEOUT)
{
}
private: private:
uWS::SSLApp& _uwsApp; uWS::SSLApp& _uwsApp;