public void RegisterRpc(Type type, PRNetworkBehaviour component, string methodName) { RpcMeta meta = new RpcMeta(); meta.baseType = type; meta.behaviourScript = component; rpcDictionary.Add(methodName, meta); }
public void ReceiveRpc(string methodName, RpcArgs args) { if (!rpcDictionary.ContainsKey(methodName)) { Debug.LogWarning("Rpc function not found."); return; } RpcMeta functionMeta = rpcDictionary[methodName]; Type[] types = args.types.Select(t => Type.GetType(t)).ToArray(); MethodInfo method = functionMeta.baseType.GetMethod(methodName, BindingFlags.Instance | BindingFlags.NonPublic, null, types, null); method.Invoke(functionMeta.behaviourScript, args.values); }
public RpcMessage(RpcMeta meta, byte[] body) { this.Meta = meta; this.Body = body != null ? body : Empty; }