This commit is contained in:
2024-10-28 18:01:42 +03:00
parent 7685f4c014
commit 1047b57013
6 changed files with 147 additions and 28 deletions

View File

@@ -18,7 +18,8 @@ class AdcDeviceNetServerASIO : public AdcDeviceNetServer
{
public:
template <traits::adc_input_char_range R>
AdcDeviceNetServerASIO(const R& id, asio::io_context& io_context) : AdcDeviceNetServer(id), _ioContext(io_context)
AdcDeviceNetServerASIO(const R& id, asio::io_context& io_context)
: AdcDeviceNetServer(id), _ioContext(io_context), _stopSignal(io_context), _restartSignal(io_context)
{
}
@@ -53,10 +54,10 @@ public:
asio::local::stream_protocol::endpoint ept(endpoint.template path<std::string>());
using srv_t = AdcNetServiceASIO<asio::local::stream_protocol, SessProtoT>;
AdcDeviceNetServer::start<Session<srv_t>>("LOCAL STREAM", this, _ioContext, ept);
} else if (endpoint.isLocalDatagram()) {
asio::local::datagram_protocol::endpoint ept(endpoint.template path<std::string>());
using srv_t = AdcNetServiceASIO<asio::local::datagram_protocol, SessProtoT>;
AdcDeviceNetServer::start<Session<srv_t>>("LOCAL DGRAM", this, _ioContext, ept);
// } else if (endpoint.isLocalDatagram()) {
// asio::local::datagram_protocol::endpoint ept(endpoint.template path<std::string>());
// using srv_t = AdcNetServiceASIO<asio::local::datagram_protocol, SessProtoT>;
// AdcDeviceNetServer::start<Session<srv_t>>("LOCAL DGRAM", this, _ioContext, ept);
} else if (endpoint.isLocalSeqpacket()) {
asio::local::seq_packet_protocol::endpoint ept(endpoint.template path<std::string>());
using srv_t = AdcNetServiceASIO<asio::local::seq_packet_protocol, SessProtoT>;
@@ -70,7 +71,7 @@ public:
// some default endpoint?!!
void start() {}
template <std::ranges::range RST, std::ranges::range RRT>
template <std::ranges::range RST = std::vector<int>, std::ranges::range RRT = std::vector<int>>
void setupSignals(const RST& stop_sig_num = std::vector<int>{SIGINT, SIGTERM},
const RRT& restart_sig_num = std::vector<int>{SIGUSR1})
requires(std::convertible_to<std::ranges::range_value_t<RST>, int> &&

View File

@@ -116,8 +116,8 @@ class AdcBaseNetServiceASIO : public SESSION_PROTOT
{
public:
#ifdef USE_OPENSSL_WITH_ASIO
static_assert(!(USE_TLS && adc_asio_tls_transport_proto_c<TRANSPORT_PROTOT>),
"INVALID 'TRANSPORT_PROTOT' TEMPLATE ARGUMENT!");
// static_assert(!(USE_TLS && adc_asio_tls_transport_proto_c<TRANSPORT_PROTOT>),
// "INVALID 'TRANSPORT_PROTOT' TEMPLATE ARGUMENT!");
static constexpr bool isTLS = USE_TLS;
#else // ignore USE_TLS
@@ -250,7 +250,8 @@ public:
template <traits::adc_time_duration_c DT = decltype(DEFAULT_ACCEPT_TIMEOUT)>
auto accept(const endpoint_t& endpoint, const DT& timeout = DEFAULT_ACCEPT_TIMEOUT)
{
return accept(endpoint, timeout);
_acceptor = srv_acceptor_t(_ioContext, endpoint);
return accept(timeout);
}
private: