Skip to content

Commit cdf2bf0

Browse files
committed
Added ExecutingRpcSender property
1 parent a168fc8 commit cdf2bf0

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

MLAPI/MonoBehaviours/Core/NetworkedBehaviour.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ public abstract class NetworkedBehaviour : MonoBehaviour
4444
/// Gets wheter or not the object has a owner
4545
/// </summary>
4646
public bool isOwnedByServer => networkedObject.isOwnedByServer;
47+
/// <summary>
48+
/// Contains the sender of the currently executing RPC. Useful for the convenience RPC methods
49+
/// </summary>
50+
protected uint ExecutingRpcSender { get; private set; }
4751

4852
/// <summary>
4953
/// Gets the NetworkedObject that owns this NetworkedBehaviour instance
@@ -636,7 +640,9 @@ private void InvokeServerRPCLocal(ulong hash, uint senderClientId, Stream stream
636640

637641
if (rpc.reflectionMethod != null)
638642
{
643+
ExecutingRpcSender = senderClientId;
639644
rpc.reflectionMethod.Invoke(this, userStream);
645+
ExecutingRpcSender = 0;
640646
}
641647

642648
if (rpc.rpcDelegate != null)
@@ -649,7 +655,9 @@ private void InvokeServerRPCLocal(ulong hash, uint senderClientId, Stream stream
649655
{
650656
if (rpc.reflectionMethod != null)
651657
{
658+
ExecutingRpcSender = senderClientId;
652659
rpc.reflectionMethod.Invoke(this, stream);
660+
ExecutingRpcSender = 0;
653661
}
654662

655663
if (rpc.rpcDelegate != null)

0 commit comments

Comments
 (0)