diff --git a/Reactor/Networking/MethodRpc/MethodRpc.cs b/Reactor/Networking/MethodRpc/MethodRpc.cs index 0833304..55ce594 100644 --- a/Reactor/Networking/MethodRpc/MethodRpc.cs +++ b/Reactor/Networking/MethodRpc/MethodRpc.cs @@ -18,11 +18,12 @@ public class MethodRpc : UnsafeCustomRpc { public delegate object HandleDelegate(InnerNetObject innerNetObject, object[] args); - public MethodRpc(BasePlugin plugin, MethodInfo method, uint id, SendOption option, RpcLocalHandling localHandling) : base(plugin, id) + public MethodRpc(BasePlugin plugin, MethodInfo method, uint id, SendOption option, RpcLocalHandling localHandling, bool sendImmediately) : base(plugin, id) { Method = method; LocalHandling = localHandling; SendOption = option; + SendImmediately = sendImmediately; if (!method.IsStatic) { @@ -56,6 +57,7 @@ public MethodRpc(BasePlugin plugin, MethodInfo method, uint id, SendOption optio public override Type InnerNetObjectType { get; } public override RpcLocalHandling LocalHandling { get; } public override SendOption SendOption { get; } + public bool SendImmediately { get; } public override void UnsafeWrite(MessageWriter writer, object? data) { @@ -82,7 +84,7 @@ public override void UnsafeHandle(InnerNetObject innerNetObject, object? data) public void Send(InnerNetObject innerNetObject, object[] args) { - UnsafeSend(innerNetObject, args); + UnsafeSend(innerNetObject, args, SendImmediately); } private static readonly MethodInfo _sendMethod = AccessTools.Method(typeof(MethodRpc), nameof(Send)); diff --git a/Reactor/Networking/MethodRpc/MethodRpcAttribute.cs b/Reactor/Networking/MethodRpc/MethodRpcAttribute.cs index e9118d9..d059236 100644 --- a/Reactor/Networking/MethodRpc/MethodRpcAttribute.cs +++ b/Reactor/Networking/MethodRpc/MethodRpcAttribute.cs @@ -13,6 +13,7 @@ public class MethodRpcAttribute : Attribute public uint Id { get; } public SendOption Option { get; set; } = SendOption.Reliable; public RpcLocalHandling LocalHandling { get; set; } = RpcLocalHandling.Before; + public bool SendImmediately { get; set; } public MethodRpcAttribute(uint id) { @@ -34,7 +35,7 @@ public static void Register(Assembly assembly, BasePlugin plugin) try { - var customRpc = new MethodRpc(plugin, method, attribute.Id, attribute.Option, attribute.LocalHandling); + var customRpc = new MethodRpc(plugin, method, attribute.Id, attribute.Option, attribute.LocalHandling, attribute.SendImmediately); PluginSingleton.Instance.CustomRpcManager.Register(customRpc); } catch (Exception e)