NetworkServerTest: ReadyMessageSetsClientReady cleanup

This commit is contained in:
vis2k 2021-06-15 17:06:51 +08:00
parent 092ff4538a
commit 26e18d7e87

View File

@ -427,7 +427,6 @@ public void ReadyMessageSetsClientReady()
{
// listen
NetworkServer.Listen(1);
Assert.That(NetworkServer.connections.Count, Is.EqualTo(0));
// add connection
CreateLocalConnectionPair(out LocalConnectionToClient connectionToClient, out _);
@ -437,17 +436,12 @@ public void ReadyMessageSetsClientReady()
connectionToClient.isAuthenticated = true;
// serialize a ready message into an arraysegment
ReadyMessage message = new ReadyMessage();
NetworkWriter writer = new NetworkWriter();
MessagePacking.Pack(message, writer);
ArraySegment<byte> segment = writer.ToArraySegment();
byte[] message = MessagePackingTest.PackToByteArray(new ReadyMessage());
// call transport.OnDataReceived with the message
// -> calls NetworkServer.OnClientReadyMessage
// -> calls SetClientReady(conn)
transport.OnServerDataReceived.Invoke(0, segment, 0);
// ready?
transport.OnServerDataReceived.Invoke(0, new ArraySegment<byte>(message), 0);
Assert.That(connectionToClient.isReady, Is.True);
}