7 #ifndef CPPWAMP_INTERNAL_UDSOPENER_HPP
8 #define CPPWAMP_INTERNAL_UDSOPENER_HPP
13 #include <boost/asio/local/stream_protocol.hpp>
14 #include <boost/asio/strand.hpp>
15 #include "../asiodefs.hpp"
16 #include "../udspath.hpp"
29 using Socket = boost::asio::local::stream_protocol::socket;
30 using SocketPtr = std::unique_ptr<Socket>;
32 template <
typename TExecutorOrStrand>
33 UdsOpener(TExecutorOrStrand&& exec, Info info)
34 : strand_(std::forward<TExecutorOrStrand>(exec)),
35 info_(std::move(info))
41 void establish(F&& callback)
46 typename std::decay<F>::type callback;
51 self->socket_.reset();
52 callback(ec, std::move(self->socket_));
53 self->socket_.reset();
57 assert(!socket_ &&
"Connect already in progress");
59 socket_.reset(
new Socket(strand_));
61 info_.options().applyTo(*socket_);
64 socket_->async_connect(info_.pathName(),
65 Connected{this, std::forward<F>(callback)});
84 #endif // CPPWAMP_INTERNAL_UDSOPENER_HPP