This commit is contained in:
Timur A. Fatkhullin
2024-10-30 00:09:30 +03:00
parent daa756d8c6
commit f14b4fdc10
3 changed files with 22 additions and 8 deletions

View File

@@ -1,5 +1,6 @@
#pragma once
#include <memory>
#include <system_error>
#include "adc_device_netmsg.h"
@@ -219,7 +220,7 @@ public:
: _ident(),
_netService(std::move(srv)),
_serverPtr(srv_ptr),
_bindDevice(_serverPtr->_devices.size() ? _serverPtr->_devices[0] : AdcDeviceNetServer::nullDevice)
_bindDevice(srv_ptr->_devices.size() ? srv_ptr->_devices.begin()->second : AdcDeviceNetServer::nullDevice)
{
if constexpr (std::is_array_v<std::remove_cvref_t<R>>) {
_ident = id;
@@ -235,8 +236,10 @@ public:
void start()
{
auto self(this->shared_from_this());
_netService.asyncReceive(
[this](std::error_code ec, message_t msg) {
[self, this](std::error_code ec, message_t msg) {
if (ec) {
stop();
} else {
@@ -248,7 +251,7 @@ public:
_netService.asyncSend(
*msg_sptr,
[msg_sptr, this](std::error_code ec) {
[self, msg_sptr, this](std::error_code ec) {
if (ec) {
stop();
} else {
@@ -360,7 +363,13 @@ public:
};
using AdcGenericNetServer::AdcGenericNetServer;
// using AdcGenericNetServer::AdcGenericNetServer;
template <traits::adc_input_char_range R>
AdcDeviceNetServer(const R& id) : AdcGenericNetServer(id), _devices()
{
}
virtual ~AdcDeviceNetServer() = default;
template <interfaces::adc_device_c DeviceT,
typename IdSerialT = traits::adc_char_identity<typename DeviceT::ident_t>,