mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
MirrorTest: ConnectClientBlockingAuthenticatedAndReady helper function
This commit is contained in:
parent
2df5357647
commit
79c067e4aa
@ -172,6 +172,21 @@ protected void ConnectClientBlockingAuthenticated(out NetworkConnectionToClient
|
||||
NetworkClient.connection.isAuthenticated = true;
|
||||
}
|
||||
|
||||
// fully connect client to local server & authenticate & set read
|
||||
protected void ConnectClientBlockingAuthenticatedAndReady(out NetworkConnectionToClient connectionToClient)
|
||||
{
|
||||
ConnectClientBlocking(out connectionToClient);
|
||||
|
||||
// authenticate server & client connections
|
||||
connectionToClient.isAuthenticated = true;
|
||||
NetworkClient.connection.isAuthenticated = true;
|
||||
|
||||
// set ready
|
||||
NetworkClient.Ready();
|
||||
ProcessMessages();
|
||||
Assert.That(connectionToClient.isReady, Is.True);
|
||||
}
|
||||
|
||||
protected void UpdateTransport()
|
||||
{
|
||||
transport.ClientEarlyUpdate();
|
||||
|
@ -386,11 +386,7 @@ public void ReadyMessageSetsClientReady()
|
||||
{
|
||||
// listen & connect
|
||||
NetworkServer.Listen(1);
|
||||
ConnectClientBlockingAuthenticated(out NetworkConnectionToClient connectionToClient);
|
||||
|
||||
// send ready message
|
||||
NetworkClient.Ready();
|
||||
ProcessMessages();
|
||||
ConnectClientBlockingAuthenticatedAndReady(out NetworkConnectionToClient connectionToClient);
|
||||
Assert.That(connectionToClient.isReady, Is.True);
|
||||
}
|
||||
|
||||
@ -400,11 +396,7 @@ public void SendCommand()
|
||||
{
|
||||
// listen & connect
|
||||
NetworkServer.Listen(1);
|
||||
ConnectClientBlockingAuthenticated(out NetworkConnectionToClient connectionToClient);
|
||||
|
||||
// need to be ready for commands
|
||||
NetworkClient.Ready();
|
||||
ProcessMessages();
|
||||
ConnectClientBlockingAuthenticatedAndReady(out NetworkConnectionToClient connectionToClient);
|
||||
|
||||
// add an identity with two networkbehaviour components
|
||||
CreateNetworked(out GameObject _, out NetworkIdentity identity, out CommandTestNetworkBehaviour comp);
|
||||
@ -431,11 +423,7 @@ public void SendCommand_CalledOnCorrectComponent()
|
||||
{
|
||||
// listen & connect
|
||||
NetworkServer.Listen(1);
|
||||
ConnectClientBlockingAuthenticated(out NetworkConnectionToClient connectionToClient);
|
||||
|
||||
// need to be ready for commands
|
||||
NetworkClient.Ready();
|
||||
ProcessMessages();
|
||||
ConnectClientBlockingAuthenticatedAndReady(out NetworkConnectionToClient connectionToClient);
|
||||
|
||||
// add an identity with two networkbehaviour components
|
||||
CreateNetworked(out GameObject _, out NetworkIdentity identity, out CommandTestNetworkBehaviour comp0, out CommandTestNetworkBehaviour comp1);
|
||||
@ -461,11 +449,7 @@ public void SendCommand_OnlyAllowedOnOwnedObjects()
|
||||
{
|
||||
// listen & connect
|
||||
NetworkServer.Listen(1);
|
||||
ConnectClientBlockingAuthenticated(out NetworkConnectionToClient connectionToClient);
|
||||
|
||||
// need to be ready for commands
|
||||
NetworkClient.Ready();
|
||||
ProcessMessages();
|
||||
ConnectClientBlockingAuthenticatedAndReady(out NetworkConnectionToClient connectionToClient);
|
||||
|
||||
// add an identity with two networkbehaviour components
|
||||
CreateNetworked(out GameObject _, out NetworkIdentity identity, out CommandTestNetworkBehaviour comp);
|
||||
@ -493,11 +477,7 @@ public void SendCommand_RequiresAuthority()
|
||||
{
|
||||
// listen & connect
|
||||
NetworkServer.Listen(1);
|
||||
ConnectClientBlockingAuthenticated(out NetworkConnectionToClient connectionToClient);
|
||||
|
||||
// need to be ready for commands
|
||||
NetworkClient.Ready();
|
||||
ProcessMessages();
|
||||
ConnectClientBlockingAuthenticatedAndReady(out NetworkConnectionToClient connectionToClient);
|
||||
|
||||
// add an identity with two networkbehaviour components
|
||||
CreateNetworked(out GameObject _, out NetworkIdentity identity, out CommandTestNetworkBehaviour comp);
|
||||
@ -627,17 +607,12 @@ public void ShowForConnection()
|
||||
{
|
||||
// listen & connect
|
||||
NetworkServer.Listen(1);
|
||||
ConnectClientBlockingAuthenticated(out NetworkConnectionToClient connectionToClient);
|
||||
ConnectClientBlockingAuthenticatedAndReady(out NetworkConnectionToClient connectionToClient);
|
||||
|
||||
// overwrite spawn message handler
|
||||
int called = 0;
|
||||
NetworkClient.ReplaceHandler<SpawnMessage>(msg => ++called, false);
|
||||
|
||||
// ready is required for ShowForConnection
|
||||
NetworkClient.Ready();
|
||||
ProcessMessages();
|
||||
Assert.That(connectionToClient.isReady, Is.True);
|
||||
|
||||
// create a gameobject and networkidentity and some unique values
|
||||
CreateNetworked(out GameObject _, out NetworkIdentity identity);
|
||||
identity.connectionToClient = connectionToClient;
|
||||
@ -655,6 +630,7 @@ public void ShowForConnection()
|
||||
public void ShowForConnection_OnlyWorksIfReady()
|
||||
{
|
||||
// listen & connect
|
||||
// DO NOT set ready this time
|
||||
NetworkServer.Listen(1);
|
||||
ConnectClientBlockingAuthenticated(out NetworkConnectionToClient connectionToClient);
|
||||
|
||||
@ -662,8 +638,6 @@ public void ShowForConnection_OnlyWorksIfReady()
|
||||
int called = 0;
|
||||
NetworkClient.ReplaceHandler<SpawnMessage>(msg => ++called, false);
|
||||
|
||||
// DO NOT set ready this time
|
||||
|
||||
// create a gameobject and networkidentity and some unique values
|
||||
CreateNetworked(out GameObject _, out NetworkIdentity identity);
|
||||
identity.connectionToClient = connectionToClient;
|
||||
@ -682,17 +656,12 @@ public void HideForConnection()
|
||||
{
|
||||
// listen & connect
|
||||
NetworkServer.Listen(1);
|
||||
ConnectClientBlockingAuthenticated(out NetworkConnectionToClient connectionToClient);
|
||||
ConnectClientBlockingAuthenticatedAndReady(out NetworkConnectionToClient connectionToClient);
|
||||
|
||||
// overwrite spawn message handler
|
||||
int called = 0;
|
||||
NetworkClient.ReplaceHandler<ObjectHideMessage>(msg => ++called, false);
|
||||
|
||||
// ready is required for ShowForConnection
|
||||
NetworkClient.Ready();
|
||||
ProcessMessages();
|
||||
Assert.That(connectionToClient.isReady, Is.True);
|
||||
|
||||
// create a gameobject and networkidentity and some unique values
|
||||
CreateNetworked(out GameObject _, out NetworkIdentity identity);
|
||||
identity.connectionToClient = connectionToClient;
|
||||
|
Loading…
Reference in New Issue
Block a user