Igor Shashuro
Igor Shashuro
This feature can be useful in case of objects destruction. In our situation, we have externa io_conxtext and we can't just stop it. The only possibility is to call async_close...
So, looks like there is no solution without waiting for callbacks, in both cases, we need to call some function (async_close or lowest_layey-cancel) and wait for handler (on_close or on_read...
if websocket_stream uses strand for execution, can we somehow handle operation_abortion in on_read before on_close event?
> waiting on the future is preventing progress of the io context. > > Simply invoke async_close with an empty lambda. The currently running async_read will complete with an error...
> You're gonna have to have some form of reference counting to know which completion handler is "last." Otherwise, how will you know when to destroy the socket? It is...
> > can we somehow handle operation_abortion in on_read before on_close event? > > No. > > https://www.boost.org/doc/libs/1_76_0/libs/beast/doc/html/beast/ref/boost__beast__websocket__stream/async_close.html > > > Send a websocket close control frame asynchronously. > >...
All ways lead to shared_ptr. Ahh. Can we expect anything else except `operation_abortion` after `on_close` or ``` std::future f = stream->async_close(code, asio::use_future); f.wait(); ``` completion? I am wondering about handling...
With one strand executor for all handlers, it should be only operation_abortion after on_close event from my understanding.
Thank you all for such a detailed explanation. I have strengthened my understanding. In most of my projects, I always wrap client beast::socket to something similar to https://developer.mozilla.org/en-US/docs/Web/API/WebSocket . This...
Maybe last question on this topic. Can we call completion_future.wait() in the handler. I mean ``` on_callback() { completion_future = async_foo(); completion_future.wait(); } ``` Will it freeze forever? How it...