Former-commit-id: f83290f7d0b5106624a37956edfc0ea623eb61a8 [formerly 7260760404ad152543aaac13fc61861c8f82c15b] [formerly 4cce81216b3f42daab22c52353acc7626d52cdad [formerly c79538e86f953f326636bdacac778d5936988eee]] Former-commit-id: 26b41fdde348870cc75535d80a4bd9a209184668 [formerly e12ae06222e2fb77a6f68c5788f0901485b95218] Former-commit-id: 6f47bc28420ebe23ce378a80324430fe898c1e99
48 lines
1.2 KiB
C++
48 lines
1.2 KiB
C++
#include <Nazara/Network/RUdpConnection.hpp>
|
|
#include <Catch/catch.hpp>
|
|
|
|
#include <Nazara/Math/Vector3.hpp>
|
|
|
|
SCENARIO("RUdpConnection", "[NETWORK][RUDPCONNECTION]")
|
|
{
|
|
GIVEN("Two RUdpConnection, one client, one server")
|
|
{
|
|
// Disabled for now
|
|
|
|
/*Nz::UInt16 port = 64266;
|
|
Nz::RUdpConnection server;
|
|
REQUIRE(server.Listen(Nz::NetProtocol_IPv4, port));
|
|
|
|
Nz::IpAddress serverIP(Nz::IpAddress::LoopbackIpV4.ToIPv4(), port);
|
|
REQUIRE(serverIP.IsValid());
|
|
|
|
Nz::RUdpConnection client;
|
|
REQUIRE(client.Listen(Nz::NetProtocol_IPv4, port + 1));
|
|
|
|
Nz::IpAddress clientIP = client.GetBoundAddress();
|
|
REQUIRE(client.Connect(serverIP));
|
|
REQUIRE(clientIP.IsValid());
|
|
|
|
WHEN("We send data from client")
|
|
{
|
|
Nz::NetPacket packet(1);
|
|
Nz::Vector3f vector123(1.f, 2.f, 3.f);
|
|
packet << vector123;
|
|
REQUIRE(client.Send(serverIP, Nz::PacketPriority_Immediate, Nz::PacketReliability_Reliable, packet));
|
|
client.Update();
|
|
|
|
THEN("We should get it on the server")
|
|
{
|
|
Nz::RUdpMessage rudpMessage;
|
|
server.Update();
|
|
|
|
REQUIRE(server.PollMessage(&rudpMessage));
|
|
|
|
Nz::Vector3f result;
|
|
rudpMessage.data >> result;
|
|
REQUIRE(result == vector123);
|
|
}
|
|
}*/
|
|
}
|
|
}
|