#include #include #include using namespace std::chrono_literals; int main() { static constexpr std::uint16_t port = 25565; int serverSendCount = 0; int clientSendCount = 0; blitz::network::EnetServer server(port); blitz::network::EnetClient client(Nz::IpAddress{"127.0.0.1:" + std::to_string(port)}); blitz::network::EnetClient client1(Nz::IpAddress{"127.0.0.1:" + std::to_string(port)}); blitz::network::EnetClient client2(Nz::IpAddress{"127.0.0.1:" + std::to_string(port)}); blitz::network::EnetClient client3(Nz::IpAddress{"127.0.0.1:" + std::to_string(port)}); blitz::network::EnetClient client4(Nz::IpAddress{"127.0.0.1:" + std::to_string(port)}); std::this_thread::sleep_for(1s); blitz_test_assert(client.GetConnection().IsConnected()); for (int i = 0; i < 5; i++) { blitz_test_assert(server.GetConnection(i)); } server.GetConnection(0)->OnKeepAlive.Connect([&server, &serverSendCount](const blitz::protocol::data::KeepAlive&) { server.GetConnection(0)->SendKeepAlive({69}); serverSendCount++; }); client.GetConnection().OnKeepAlive.Connect([&client, &clientSendCount](const blitz::protocol::data::KeepAlive&) { client.GetConnection().SendKeepAlive({69}); clientSendCount++; }); std::this_thread::sleep_for(1s); client.GetConnection().SendKeepAlive({69}); std::this_thread::sleep_for(1s); blitz_test_assert(serverSendCount > 10 && clientSendCount > 10); return BLITZ_TEST_SUCCESSFUL; }