AdcNetServiceASIOBase: add acceptor_t inner class
This commit is contained in:
@@ -5,13 +5,13 @@
|
||||
#include "../net/asio/adc_netservice_asio.h"
|
||||
|
||||
template <typename T>
|
||||
void receive(T& srv)
|
||||
void receive(T srv)
|
||||
{
|
||||
srv.asyncReceive(
|
||||
[&srv](std::error_code ec, std::string msg) {
|
||||
if (!ec) {
|
||||
std::cout << "Received: [" << msg << "]\n";
|
||||
receive(srv);
|
||||
receive(std::move(srv));
|
||||
} else {
|
||||
std::cout << "Received: " << ec.message() << "\n";
|
||||
}
|
||||
@@ -30,37 +30,23 @@ int main()
|
||||
|
||||
asio::io_context ctx;
|
||||
|
||||
adc::impl::AdcNetServiceASIOBase<asio::ip::tcp, adc::AdcStopSeqSessionProto<>> srv(ctx);
|
||||
using srv_t = adc::impl::AdcNetServiceASIOBase<asio::ip::tcp, adc::AdcStopSeqSessionProto<>>;
|
||||
|
||||
// adc::impl::AdcNetServiceASIOBase<asio::ip::tcp, adc::AdcStopSeqSessionProto<>>::asio_async_ctx_t srv_ctx;
|
||||
// srv_ctx.accept_comp_token = [](std::error_code ec) {
|
||||
typename srv_t::acceptor_t acc(ctx, ept_c);
|
||||
|
||||
// };
|
||||
|
||||
// srv.asyncAccept(ept_s, srv_ctx, std::chrono::seconds(120));
|
||||
// srv.asyncConnect(ept_c, [](std::error_code ec) {
|
||||
|
||||
// });
|
||||
|
||||
// adc::impl::AdcNetServiceASIOBase<asio::ip::tcp, adc::AdcStopSeqSessionProto<>>::contx_t s_ctx;
|
||||
|
||||
// srv.asyncConnect(ept_c, s_ctx);
|
||||
// auto res = srv.asyncConnect(ept_c, asio::use_awaitable);
|
||||
|
||||
srv.asyncAccept(ept_c, [&srv](std::error_code ec) {
|
||||
acc.asyncAccept([](std::error_code ec, srv_t srv) {
|
||||
if (!ec) {
|
||||
std::cout << "New connection\n";
|
||||
|
||||
// srv.asyncReceive(
|
||||
// [](std::error_code ec, std::string msg) {
|
||||
// if (!ec) {
|
||||
// std::cout << "Received: [" << msg << "]\n";
|
||||
// } else {
|
||||
// std::cout << "Received: " << ec.message() << "\n";
|
||||
// }
|
||||
// },
|
||||
// std::chrono::minutes(1));
|
||||
receive(srv);
|
||||
// receive(std::move(srv));
|
||||
srv.asyncReceive(
|
||||
[](std::error_code ec, std::string msg) {
|
||||
if (!ec) {
|
||||
std::cout << "Received: [" << msg << "]\n";
|
||||
// receive(std::move(srv));
|
||||
} else {
|
||||
std::cout << "Received: " << ec.message() << "\n";
|
||||
}
|
||||
},
|
||||
std::chrono::minutes(1));
|
||||
} else {
|
||||
std::cout << "ACCEPT ERR: " << ec.message() << "\n";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user