diff --git a/Assets/Mirror/Tests/Editor/NetworkIdentityTests.cs b/Assets/Mirror/Tests/Editor/NetworkIdentityTests.cs index d0134c85d..19b0e14b1 100644 --- a/Assets/Mirror/Tests/Editor/NetworkIdentityTests.cs +++ b/Assets/Mirror/Tests/Editor/NetworkIdentityTests.cs @@ -1338,5 +1338,27 @@ public void RebuildObserversAddsOwnReadyPlayer() identity.RebuildObservers(true); Assert.That(identity.observers.ContainsKey(identity.connectionToClient.connectionId)); } + + // RebuildObservers should always add the own ready connection + // (if any). fixes https://github.com/vis2k/Mirror/issues/692 + [Test] + public void RebuildObserversOnlyAddsOwnPlayerIfReady() + { + // add at least one observers component, otherwise it will just add + // all server connections + gameObject.AddComponent(); + + // add own player connection that isn't ready + ULocalConnectionToClient connection = new ULocalConnectionToClient(); + connection.connectionToServer = new ULocalConnectionToServer(); + identity.connectionToClient = connection; + + // call OnStartServer so that observers dict is created + identity.OnStartServer(); + + // rebuild shouldn't add own player because conn wasn't set ready + identity.RebuildObservers(true); + Assert.That(!identity.observers.ContainsKey(identity.connectionToClient.connectionId)); + } } }