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
This commit is contained in:
James Frowen 2020-09-06 15:14:05 +01:00 committed by GitHub
parent a30e8fcd85
commit 2033f7d009
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 0 additions and 71 deletions

View File

@ -207,17 +207,6 @@ protected void SendCommandInternal(Type invokeClass, string cmdName, NetworkWrit
ClientScene.readyConnection.Send(message, channelId);
}
/// <summary>
/// Manually invoke a Command.
/// </summary>
/// <param name="cmdHash">Hash of the Command name.</param>
/// <param name="reader">Parameters to pass to the command.</param>
/// <returns>Returns true if successful.</returns>
[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);
}
/// <summary>
/// Manually invoke an RPC function.
/// </summary>
/// <param name="rpcHash">Hash of the RPC name.</param>
/// <param name="reader">Parameters to pass to the RPC function.</param>
/// <returns>Returns true if successful.</returns>
[EditorBrowsable(EditorBrowsableState.Never)]
public virtual bool InvokeRPC(int rpcHash, NetworkReader reader)
{
return RemoteCallHelper.InvokeHandlerDelegate(rpcHash, MirrorInvokeType.ClientRpc, reader, this);
}
#endregion
#region Helpers

View File

@ -392,31 +392,6 @@ public void SendCommandInternal()
GameObject.DestroyImmediate(transportGO);
}
[Test]
public void InvokeCommand()
{
// add command component
NetworkBehaviourSendCommandInternalComponent comp = gameObject.AddComponent<NetworkBehaviourSendCommandInternalComponent>();
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<NetworkBehaviourSendRPCInternalComponent>();
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()
{