From 2033f7d009b11d11f968c7ce40f09bca05e5d0b9 Mon Sep 17 00:00:00 2001 From: James Frowen Date: Sun, 6 Sep 2020 15:14:05 +0100 Subject: [PATCH] breaking: Removing manual invoke for Cmd and RPC (#2223) * Removing manual invoke for Cmd and RPC There should be no reason to manaully invoke remote code they are marked with EditorBrowsableState.Never which implies they should not be called by the user * removing tests --- Assets/Mirror/Runtime/NetworkBehaviour.cs | 22 --------- .../Tests/Editor/NetworkBehaviourTests.cs | 49 ------------------- 2 files changed, 71 deletions(-) diff --git a/Assets/Mirror/Runtime/NetworkBehaviour.cs b/Assets/Mirror/Runtime/NetworkBehaviour.cs index 9878f1773..df2903265 100644 --- a/Assets/Mirror/Runtime/NetworkBehaviour.cs +++ b/Assets/Mirror/Runtime/NetworkBehaviour.cs @@ -207,17 +207,6 @@ protected void SendCommandInternal(Type invokeClass, string cmdName, NetworkWrit ClientScene.readyConnection.Send(message, channelId); } - /// - /// Manually invoke a Command. - /// - /// Hash of the Command name. - /// Parameters to pass to the command. - /// Returns true if successful. - [EditorBrowsable(EditorBrowsableState.Never)] - public virtual bool InvokeCommand(int cmdHash, NetworkReader reader) - { - return RemoteCallHelper.InvokeHandlerDelegate(cmdHash, MirrorInvokeType.Command, reader, this); - } #endregion #region Client RPCs @@ -295,17 +284,6 @@ protected void SendTargetRPCInternal(NetworkConnection conn, Type invokeClass, s conn.Send(message, channelId); } - /// - /// Manually invoke an RPC function. - /// - /// Hash of the RPC name. - /// Parameters to pass to the RPC function. - /// Returns true if successful. - [EditorBrowsable(EditorBrowsableState.Never)] - public virtual bool InvokeRPC(int rpcHash, NetworkReader reader) - { - return RemoteCallHelper.InvokeHandlerDelegate(rpcHash, MirrorInvokeType.ClientRpc, reader, this); - } #endregion #region Helpers diff --git a/Assets/Mirror/Tests/Editor/NetworkBehaviourTests.cs b/Assets/Mirror/Tests/Editor/NetworkBehaviourTests.cs index 90ec8acef..99e2601a1 100644 --- a/Assets/Mirror/Tests/Editor/NetworkBehaviourTests.cs +++ b/Assets/Mirror/Tests/Editor/NetworkBehaviourTests.cs @@ -392,31 +392,6 @@ public void SendCommandInternal() GameObject.DestroyImmediate(transportGO); } - [Test] - public void InvokeCommand() - { - // add command component - NetworkBehaviourSendCommandInternalComponent comp = gameObject.AddComponent(); - Assert.That(comp.called, Is.EqualTo(0)); - - // register the command delegate, otherwise it's not found - int registeredHash = RemoteCallHelper.RegisterDelegate(typeof(NetworkBehaviourSendCommandInternalComponent), - nameof(NetworkBehaviourSendCommandInternalComponent.CommandGenerated), - MirrorInvokeType.Command, - NetworkBehaviourSendCommandInternalComponent.CommandGenerated, - false); - - // invoke command - int cmdHash = RemoteCallHelper.GetMethodHash( - typeof(NetworkBehaviourSendCommandInternalComponent), - nameof(NetworkBehaviourSendCommandInternalComponent.CommandGenerated)); - comp.InvokeCommand(cmdHash, new NetworkReader(new byte[0])); - Assert.That(comp.called, Is.EqualTo(1)); - - // clean up - RemoteCallHelper.RemoveDelegate(registeredHash); - } - [Test] public void SendRPCInternal() { @@ -595,30 +570,6 @@ public void SendTargetRPCInternal() GameObject.DestroyImmediate(transportGO); } - [Test] - public void InvokeRPC() - { - // add command component - NetworkBehaviourSendRPCInternalComponent comp = gameObject.AddComponent(); - Assert.That(comp.called, Is.EqualTo(0)); - - // register the command delegate, otherwise it's not found - int registeredHash = RemoteCallHelper.RegisterDelegate(typeof(NetworkBehaviourSendRPCInternalComponent), - nameof(NetworkBehaviourSendRPCInternalComponent.RPCGenerated), - MirrorInvokeType.ClientRpc, - NetworkBehaviourSendRPCInternalComponent.RPCGenerated); - - // invoke command - int rpcHash = RemoteCallHelper.GetMethodHash( - typeof(NetworkBehaviourSendRPCInternalComponent), - nameof(NetworkBehaviourSendRPCInternalComponent.RPCGenerated)); - comp.InvokeRPC(rpcHash, new NetworkReader(new byte[0])); - Assert.That(comp.called, Is.EqualTo(1)); - - // clean up - RemoteCallHelper.RemoveDelegate(registeredHash); - } - [Test] public void RegisterDelegateDoesntOverwrite() {