This commit is contained in:
vis2k 2021-06-18 16:48:59 +08:00
parent 651020852b
commit 8338d02301

View File

@ -370,9 +370,11 @@ public void Send_ClientToServerMessage_MaxMessageSize()
NetworkServer.Listen(1);
ConnectClientBlocking(out _);
// send message & process
// calculate max := transport.max - message header
int transportMax = transport.GetMaxPacketSize(Channels.Reliable);
int messageMax = transportMax - MessagePacking.HeaderSize;
// send message & process
NetworkClient.Send(new VariableSizedMessage(messageMax));
ProcessMessages();
@ -392,9 +394,11 @@ public void Send_ServerToClientMessage_MaxMessageSize()
NetworkServer.Listen(1);
ConnectClientBlocking(out NetworkConnectionToClient connectionToClient);
// send message & process
// calculate max := transport.max - message header
int transportMax = transport.GetMaxPacketSize(Channels.Reliable);
int messageMax = transportMax - MessagePacking.HeaderSize;
// send message & process
connectionToClient.Send(new VariableSizedMessage(messageMax));
ProcessMessages();
@ -414,9 +418,11 @@ public void Send_ClientToServerMessage_LargerThanMaxMessageSize()
NetworkServer.Listen(1);
ConnectClientBlocking(out _);
// send message & process
// calculate max := transport.max - message header
int transportMax = transport.GetMaxPacketSize(Channels.Reliable);
int messageMax = transportMax - MessagePacking.HeaderSize;
// send message & process
LogAssert.Expect(LogType.Error, $"NetworkConnection.ValidatePacketSize: cannot send packet larger than {transportMax} bytes, was {transportMax + 1} bytes");
NetworkClient.Send(new VariableSizedMessage(messageMax + 1));
ProcessMessages();
@ -437,9 +443,11 @@ public void Send_ServerToClientMessage_LargerThanMaxMessageSize()
NetworkServer.Listen(1);
ConnectClientBlocking(out NetworkConnectionToClient connectionToClient);
// send message & process
// calculate max := transport.max - message header
int transportMax = transport.GetMaxPacketSize(Channels.Reliable);
int messageMax = transportMax - MessagePacking.HeaderSize;
// send message & process
LogAssert.Expect(LogType.Error, $"NetworkConnection.ValidatePacketSize: cannot send packet larger than {transportMax} bytes, was {transportMax + 1} bytes");
connectionToClient.Send(new VariableSizedMessage(messageMax + 1));
ProcessMessages();