...
This commit is contained in:
parent
672788d59d
commit
60fa49bc29
@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
@ -63,6 +64,9 @@ public:
|
|||||||
fromRange(ept);
|
fromRange(ept);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
virtual ~AdcEndpointParser() = default;
|
||||||
|
|
||||||
template <traits::adc_input_char_range R>
|
template <traits::adc_input_char_range R>
|
||||||
requires std::ranges::contiguous_range<R>
|
requires std::ranges::contiguous_range<R>
|
||||||
bool fromRange(const R& ept)
|
bool fromRange(const R& ept)
|
||||||
@ -88,19 +92,23 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
_proto = std::string_view{_endpoint.begin(), found.begin()};
|
_proto = std::string_view{_endpoint.begin(), found.begin()};
|
||||||
for (auto& valid_proto : validProtoMarks) {
|
// for (auto& valid_proto : validProtoMarks) {
|
||||||
_isValid = _proto == valid_proto;
|
// _isValid = _proto == valid_proto;
|
||||||
if (_isValid) {
|
// if (_isValid) {
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (!_isValid) {
|
// if (!_isValid) {
|
||||||
|
// return _isValid;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// _isValid = false;
|
||||||
|
|
||||||
|
if (!checkProtoMark(_proto)) {
|
||||||
return _isValid;
|
return _isValid;
|
||||||
}
|
}
|
||||||
|
|
||||||
_isValid = false;
|
|
||||||
|
|
||||||
_host = std::string_view{found.end(), _endpoint.end()};
|
_host = std::string_view{found.end(), _endpoint.end()};
|
||||||
if (_proto == protoMarkLocal) { // local proto allows only hostname
|
if (_proto == protoMarkLocal) { // local proto allows only hostname
|
||||||
_path = std::string_view();
|
_path = std::string_view();
|
||||||
@ -220,6 +228,13 @@ protected:
|
|||||||
int _port;
|
int _port;
|
||||||
bool _isValid;
|
bool _isValid;
|
||||||
|
|
||||||
|
|
||||||
|
virtual bool checkProtoMark(std::string_view proto_mark)
|
||||||
|
{
|
||||||
|
return std::ranges::any_of(AdcEndpointParser::validProtoMarks,
|
||||||
|
[proto_mark](const auto& el) { return el == proto_mark; });
|
||||||
|
}
|
||||||
|
|
||||||
enum EndpointPart { PROTO_PART, HOST_PART, PATH_PART };
|
enum EndpointPart { PROTO_PART, HOST_PART, PATH_PART };
|
||||||
|
|
||||||
template <traits::adc_view_or_output_char_range R>
|
template <traits::adc_view_or_output_char_range R>
|
||||||
|
|||||||
@ -266,7 +266,8 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
// NOTE: CANNOT MOVE asio::streambuf CORRECTLY?!!!
|
// NOTE: CANNOT MOVE asio::streambuf CORRECTLY?!!!
|
||||||
AdcNetServiceASIOBase(AdcNetServiceASIOBase&& other) = delete;
|
AdcNetServiceASIOBase(AdcNetServiceASIOBase&& other) = default;
|
||||||
|
// AdcNetServiceASIOBase(AdcNetServiceASIOBase&& other) = delete;
|
||||||
AdcNetServiceASIOBase(const AdcNetServiceASIOBase&) = delete; // no copy constructor!
|
AdcNetServiceASIOBase(const AdcNetServiceASIOBase&) = delete; // no copy constructor!
|
||||||
|
|
||||||
virtual ~AdcNetServiceASIOBase() {}
|
virtual ~AdcNetServiceASIOBase() {}
|
||||||
@ -274,7 +275,8 @@ public:
|
|||||||
|
|
||||||
AdcNetServiceASIOBase& operator=(const AdcNetServiceASIOBase&) = delete;
|
AdcNetServiceASIOBase& operator=(const AdcNetServiceASIOBase&) = delete;
|
||||||
|
|
||||||
AdcNetServiceASIOBase& operator=(AdcNetServiceASIOBase&& other) = delete;
|
// AdcNetServiceASIOBase& operator=(AdcNetServiceASIOBase&& other) = delete;
|
||||||
|
AdcNetServiceASIOBase& operator=(AdcNetServiceASIOBase&& other) = default;
|
||||||
|
|
||||||
|
|
||||||
constexpr netservice_ident_t ident() const
|
constexpr netservice_ident_t ident() const
|
||||||
@ -362,6 +364,8 @@ public:
|
|||||||
template <typename TokenT, traits::adc_time_duration_c TimeoutT = decltype(DEFAULT_RECEIVE_TIMEOUT)>
|
template <typename TokenT, traits::adc_time_duration_c TimeoutT = decltype(DEFAULT_RECEIVE_TIMEOUT)>
|
||||||
auto asyncReceive(TokenT&& token, const TimeoutT& timeout = DEFAULT_RECEIVE_TIMEOUT)
|
auto asyncReceive(TokenT&& token, const TimeoutT& timeout = DEFAULT_RECEIVE_TIMEOUT)
|
||||||
{
|
{
|
||||||
|
static asio::streambuf _streamBuffer;
|
||||||
|
|
||||||
// check completion token signature and deduce message type
|
// check completion token signature and deduce message type
|
||||||
// if constexpr (!adc_asio_special_comp_token_c<TokenT> && !is_async_ctx_t) {
|
// if constexpr (!adc_asio_special_comp_token_c<TokenT> && !is_async_ctx_t) {
|
||||||
if constexpr (!adc_asio_special_comp_token_c<TokenT>) {
|
if constexpr (!adc_asio_special_comp_token_c<TokenT>) {
|
||||||
@ -562,7 +566,7 @@ protected:
|
|||||||
|
|
||||||
socket_t _socket;
|
socket_t _socket;
|
||||||
|
|
||||||
asio::streambuf _streamBuffer;
|
// asio::streambuf _streamBuffer;
|
||||||
|
|
||||||
std::queue<std::vector<char>> _receiveQueue;
|
std::queue<std::vector<char>> _receiveQueue;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user