Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/radproto/socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<void(const boost::system::error_code&, const std::optional<Packet>&, const boost::asio::ip::udp::endpoint&)>& callback);
void asyncSend(const Packet& response, const boost::asio::ip::udp::endpoint& destination, const std::function<void(const boost::system::error_code&)>& callback);
void close(boost::system::error_code& ec);
Expand Down
4 changes: 2 additions & 2 deletions src/socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
}
Expand Down
12 changes: 6 additions & 6 deletions tests/socket_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace
BOOST_REQUIRE(!ec);
}

void checkReceive(const error_code& ec, const std::optional<RadProto::Packet>& p, boost::asio::ip::udp::endpoint source)
void checkReceive(const error_code& ec, const std::optional<RadProto::Packet>& p, boost::asio::ip::udp::endpoint /*source*/)
{
callbackReceiveCalled = true;
BOOST_REQUIRE(!ec);
Expand Down Expand Up @@ -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));

}

Expand All @@ -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.");
Expand Down
Loading