diff --git a/include/radproto/socket.h b/include/radproto/socket.h index a4f3745..54cc431 100644 --- a/include/radproto/socket.h +++ b/include/radproto/socket.h @@ -12,7 +12,7 @@ namespace RadProto class Socket { public: - Socket(boost::asio::io_service& io_service, const std::string& secret, uint16_t port); + Socket(boost::asio::io_context& io_context, const std::string& secret, uint16_t port); void asyncReceive(const std::function&, const boost::asio::ip::udp::endpoint&)>& callback); void asyncSend(const Packet& response, const boost::asio::ip::udp::endpoint& destination, const std::function& callback); void close(boost::system::error_code& ec); diff --git a/src/socket.cpp b/src/socket.cpp index fa46d93..a6c49bf 100644 --- a/src/socket.cpp +++ b/src/socket.cpp @@ -24,8 +24,8 @@ std::string packetTypeToString(int type) } using Socket = RadProto::Socket; -Socket::Socket(boost::asio::io_service& io_service, const std::string& secret, uint16_t port) - : m_socket(io_service, udp::endpoint(udp::v4(), port)), +Socket::Socket(boost::asio::io_context& io_context, const std::string& secret, uint16_t port) + : m_socket(io_context, udp::endpoint(udp::v4(), port)), m_secret(secret) { } diff --git a/tests/socket_tests.cpp b/tests/socket_tests.cpp index 55fea61..64b4dc8 100644 --- a/tests/socket_tests.cpp +++ b/tests/socket_tests.cpp @@ -35,7 +35,7 @@ namespace BOOST_REQUIRE(!ec); } - void checkReceive(const error_code& ec, const std::optional& p, boost::asio::ip::udp::endpoint source) + void checkReceive(const error_code& ec, const std::optional& p, boost::asio::ip::udp::endpoint /*source*/) { callbackReceiveCalled = true; BOOST_REQUIRE(!ec); @@ -112,9 +112,9 @@ BOOST_AUTO_TEST_SUITE(SocketTests) BOOST_AUTO_TEST_CASE(TestConstructor) { - boost::asio::io_service io_service; + boost::asio::io_context io_context; - BOOST_CHECK_NO_THROW(RadProto::Socket s(io_service, "secret", 3000)); + BOOST_CHECK_NO_THROW(RadProto::Socket s(io_context, "secret", 3000)); } @@ -129,17 +129,17 @@ BOOST_AUTO_TEST_CASE(TestAsyncSend) RadProto::Packet p(1, 208, auth, attributes, vendorSpecific); - boost::asio::io_service io_service; + boost::asio::io_context io_context; boost::asio::ip::udp::endpoint destination(boost::asio::ip::address_v4::from_string("127.0.0.1"), 3000); - RadProto::Socket s(io_service, "secret", 3000); + RadProto::Socket s(io_context, "secret", 3000); s.asyncSend(p, destination, checkSend); s.asyncReceive(checkReceive); - io_service.run(); + io_context.run(); BOOST_CHECK_MESSAGE(callbackSendCalled, "Function asyncSend hasn't called checkSend."); BOOST_CHECK_MESSAGE(callbackReceiveCalled, "Function asyncReceive hasn't called checkReceive.");