Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into 2021.11.9
Browse files Browse the repository at this point in the history
  • Loading branch information
js6pak committed Dec 2, 2021
2 parents 8e8beaf + c96f120 commit bc9b8ea
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions Reactor/Networking/MethodRpc/MethodRpc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
{
Expand All @@ -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));
Expand Down
3 changes: 2 additions & 1 deletion Reactor/Networking/MethodRpc/MethodRpcAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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<ReactorPlugin>.Instance.CustomRpcManager.Register(customRpc);
}
catch (Exception e)
Expand Down

0 comments on commit bc9b8ea

Please sign in to comment.