NetworkServerTest: Send_ServerToClientMessage

This commit is contained in:
vis2k 2021-06-16 17:57:47 +08:00
parent 764cd988c5
commit 185468ea38

View File

@ -326,6 +326,25 @@ public void Send_ClientToServerMessage()
Assert.That(called, Is.EqualTo(1));
}
[Test]
public void Send_ServerToClientMessage()
{
// register a message handler
int called = 0;
NetworkClient.RegisterHandler<TestMessage1>(msg => ++called, false);
// listen & connect a client
NetworkServer.Listen(1);
ConnectClientBlocking(out NetworkConnectionToClient connectionToClient);
// send message & process
connectionToClient.Send(new TestMessage1());
ProcessMessages();
// did it get through?
Assert.That(called, Is.EqualTo(1));
}
[Test]
public void OnDataReceivedInvalidConnectionId()
{