private object InvokeReflected(RPCReference rpcReference, Stream stream) { using (PooledBitReader reader = PooledBitReader.Get(stream)) { for (int i = 0; i < parameterTypes.Length; i++) { parameterRefs[i] = reader.ReadObjectPacked(parameterTypes[i]); } return(method.Invoke(rpcReference.networkBehaviour, parameterRefs)); } }
public object Invoke(RPCReference rpcReference, ulong senderClientID, Stream stream) { if (requireOwnership == true && senderClientID != rpcReference.networkBehaviour.ownerID) { Debug.LogWarning("Only the owner can invoke a Server RPC that is marked to require ownership. (Invoked by client ID '" + senderClientID + "' | Current owner: '" + rpcReference.networkBehaviour.ownerID + "')."); return(null); } //target.executingRpcSender = senderClientId; if (stream.Position == 0) { if (useDelegate) { return(InvokeDelegate(rpcReference, senderClientID, stream)); } else { return(InvokeReflected(rpcReference, stream)); } } else { // Create a new stream so that the stream they get ONLY contains user data and not MLAPI headers using (PooledBitStream userStream = PooledBitStream.Get()) { userStream.CopyUnreadFrom(stream); userStream.Position = 0; if (useDelegate) { return(InvokeDelegate(rpcReference, senderClientID, stream)); } else { return(InvokeReflected(rpcReference, stream)); } } } }
private object InvokeDelegate(RPCReference rpcReference, ulong senderClientId, Stream stream) { rpcReference.rpcDelegates[index](senderClientId, stream); return(null); }