Esempio n. 1
0
        public virtual object Execute(object host, RPCParameter parameter)
        {
            //var method = parameter.GetRPCMethod();
            var args = new object[] { parameter };

            return(Method.Invoke(host, args));
        }
Esempio n. 2
0
        public object GetHostObject(RPCParameter arg)
        {
            var result = Router.GetHostObjectImpl(arg);

            if (result != null)
            {
                return(result);
            }
            return(null);
        }
Esempio n. 3
0
        public static void DoReturn(RPCParameter arg, R retValue)
        {
            var  pkg   = new PkgWriter(arg.GetPkgSize());
            byte route = (byte)ERouteTarget.Self | (byte)ERouteTarget.ReturnFlag;

            pkg.Write((byte)route);
            pkg.Write(arg.SerialId);
            retValue.WriteObject(pkg);
            pkg.SendBuffer(arg.Connect);
            pkg.Dispose();
        }
Esempio n. 4
0
 public virtual object DoExecute(RPCParameter arg, RPCExec exec, object host)
 {
     try
     {
         return(exec.Execute(host, arg));
     }
     catch (Exception ex)
     {
         Profiler.Log.WriteException(ex);
         return(null);
     }
 }
Esempio n. 5
0
        public void SetMethod(System.Reflection.MethodInfo mtd, UInt16 index, System.Type paramType)
        {
            Index       = index;
            Method      = mtd;
            HashString  = RPCParameter.GetRPCCode(mtd);
            MethordHash = UniHash.APHash(HashString);

            mParamType = paramType;
            if (paramType.BaseType != null && paramType.BaseType.IsGenericType)
            {
                var typeArgs = paramType.BaseType.GenericTypeArguments;
                if (typeArgs.Length > 1)
                {
                    if (typeArgs[0].FullName != paramType.FullName)
                    {
                        System.Diagnostics.Debugger.Break();
                    }
                }
            }
        }
Esempio n. 6
0
        public void RegRPC(RPCParameter arg, System.Reflection.MethodInfo method, string macro)
        {
            var desc = arg.GetMethodBinder();

            if (desc.Method != null)
            {
                System.Diagnostics.Debug.Assert(desc.Method == method);
                //同一个RPCParameter被多个RPCMethod作为参数使用,这是不符合系统需求的
                System.Diagnostics.Debug.Assert(false);
                return;
            }

            var index = desc.Index;

            if (index == MaxRPC)
            {
                index = FindValidIndex();
            }

            desc.SetMethod(method, index, arg.GetType());
            desc.Macro = macro;

            var rpcAttr = Rtti.AttributeHelper.GetCustomAttribute(method, typeof(RPCCallAttribute).FullName, true);

            if (rpcAttr != null)
            {
                var cattr = rpcAttr as RPCCallAttribute;
                if (cattr != null)
                {
                    desc.CallAttr = cattr;
                }
            }
            else
            {
                desc.CallAttr = null;
            }

            HashExec[desc.MethordHash] = desc;
            mExec[index] = desc;
        }
Esempio n. 7
0
 public override object GetHostObjectImpl(RPCParameter arg)
 {
     return(HostObject);
 }
Esempio n. 8
0
 public virtual string GetHostObjectName(RPCParameter arg)
 {
     return("");
 }
Esempio n. 9
0
 public virtual object GetHostObjectImpl(RPCParameter arg)
 {
     return(null);
 }
Esempio n. 10
0
 public object DoExecute(RPCParameter arg, RPCExec exec, object host)
 {
     return(Router.DoExecute(arg, exec, host));
 }
Esempio n. 11
0
 public string GetHostObjectName(RPCParameter arg)
 {
     return(Router.GetHostObjectName(arg));
 }
Esempio n. 12
0
        public UInt32 GetMethodHash()
        {
            var code = RPCParameter.GetRPCCode(Method);

            return((UInt32)UniHash.APHash(code));
        }
Esempio n. 13
0
 public virtual void DestroyParameter(RPCParameter obj)
 {
 }