5 #ifndef SKYWAY_UDP_SOCKET_FUTURE_H 6 #define SKYWAY_UDP_SOCKET_FUTURE_H 8 #include <fruit/fruit.h> 11 #include <boost/asio.hpp> 12 #include <boost/asio/use_future.hpp> 17 using boost::asio::ip::address;
18 using boost::asio::ip::udp;
19 using fruit::Component;
20 using fruit::createComponent;
21 using fruit::Injector;
27 ASSISTED(udp::endpoint) target_socket,
28 ASSISTED(std::shared_ptr<std::function<
void(std::vector<uint8_t>)>>)
32 virtual void Start()
override;
33 virtual void Stop()
override;
34 virtual unsigned short Port()
override;
35 virtual void SendData(std::vector<uint8_t> vec)
override;
46 std::shared_ptr<std::function<void(std::vector<uint8_t>)>>
callback_;
56 new boost::asio::io_service()};
63 void send_handler(
const boost::system::error_code &error, std::size_t len);
69 udp::endpoint, std::shared_ptr<std::function<void(std::vector<uint8_t>)>>)>;
73 #endif // SKYWAY_UDP_SOCKET_FUTURE_H udp::endpoint local_endpoint_
fruit::Component< SocketFactory > getUdpSocketComponent()
udp::endpoint getFreePort()
virtual void Stop() override
virtual void Start() override
std::unique_ptr< std::thread > recv_thread_
void send_handler(const boost::system::error_code &error, std::size_t len)
INJECT(UdpSocket(ASSISTED(udp::endpoint) target_socket, callback))
std::unique_ptr< udp::socket > send_socket_
std::function< std::unique_ptr< Socket >(udp::endpoint, std::shared_ptr< std::function< void(std::vector< uint8_t >)> >)> SocketFactory
udp::endpoint target_socket_
virtual unsigned short Port() override
std::unique_ptr< boost::asio::io_service > send_io_service_
std::shared_ptr< std::function< void(std::vector< uint8_t >)> > callback_
virtual void SendData(std::vector< uint8_t > vec) override