Ejemplo n.º 1
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);
     }
 }
Ejemplo n.º 2
0
        public void SystemRegExe(UInt16 index, System.Type argType, RPCExec binder)
        {
            var arg = System.Activator.CreateInstance(argType) as RPCParameter;
            var old = arg.GetMethodBinder();

            arg.SystemSetMethodBinder(binder);

            System.Diagnostics.Debug.Assert(old.Method != null);

            binder.SetMethod(old.Method, index, old.ParamType);

            binder.CallAttr       = old.CallAttr;
            binder.OnWritePackage = old.OnWritePackage;
            binder.Macro          = old.Macro;


            mExec[old.Index]             = null;
            mExec[index]                 = binder;
            HashExec[binder.MethordHash] = binder;
        }
Ejemplo n.º 3
0
        public object Execute(PkgReader pkg, Net.NetConnection connect, ref RPCRouter.RouteData routeInfo)
        {
            UInt16 rpcIndex    = 0;
            UInt32 rpcHash     = 0;
            bool   hasReturn   = false;
            bool   isHashIndex = pkg.IsHashIndex();

            if (isHashIndex)
            {
                hasReturn = pkg.IsHasReturn();
                pkg.Read(out rpcHash);
            }
            else
            {
                pkg.Read(out rpcIndex);
                hasReturn = (rpcIndex & WaitFlag) != 0 ? true : false;
            }
            if (hasReturn != pkg.IsHasReturn())
            {
                System.Diagnostics.Debug.Assert(false);
            }
            UInt16 serialId = 0;

            if (hasReturn)
            {
                pkg.Read(out serialId);
                rpcIndex = (UInt16)(rpcIndex & MaxRPC);
            }
            RPCExec exec = null;

            if (isHashIndex)
            {
                exec = GetExecByHash(rpcHash);
            }
            else
            {
                exec = GetExecByIndex(rpcIndex);
            }
            if (exec == null)
            {
                System.Diagnostics.Debug.WriteLine($"RPC GetExecByIndex is null:{rpcIndex}");
                return(null);
            }
            var parameter = exec.CreateParameter(pkg);

            parameter.SerialId    = serialId;
            parameter.RouteInfo   = routeInfo;
            parameter.Connect     = connect;
            parameter.ExtraReader = pkg;
            object host = parameter.GetHostObject();

            if (host == null)
            {
                exec.DestroyParameter(parameter);
                System.Diagnostics.Debug.WriteLine($"RPC HostObject is null:{parameter.GetType().FullName}");
                return(null);
            }
            var authority = parameter.GetAuthority(host);

            if (authority < exec.CallAttr.LimitLevel)
            {//超越权限
                exec.DestroyParameter(parameter);
                System.Diagnostics.Debug.WriteLine($"Over Authority[{authority}<{exec.CallAttr.LimitLevel.ToString()}]:{parameter.GetHostObjectName()}=>{parameter.GetRPCMethod().Name}");
                return(null);
            }

            try
            {
                return(parameter.DoExecute(exec, host));
            }
            catch (Exception ex)
            {
                Profiler.Log.WriteException(ex);
                return(null);
            }
            finally
            {
                exec.DestroyParameter(parameter);
            }
        }
Ejemplo n.º 4
0
 public abstract void SystemSetMethodBinder(RPCExec exec);
Ejemplo n.º 5
0
 public object DoExecute(RPCParameter arg, RPCExec exec, object host)
 {
     return(Router.DoExecute(arg, exec, host));
 }
Ejemplo n.º 6
0
 public void SystemSetMethodBinder(RPCExec exec)
 {
     MethodBinder = exec;
 }
Ejemplo n.º 7
0
 public override object DoExecute(RPCExec exec, object host)
 {
     return(ParamImpl.DoExecute(this, exec, host));
 }
Ejemplo n.º 8
0
 public override void SystemSetMethodBinder(RPCExec exec)
 {
     ParamImpl.SystemSetMethodBinder(exec);
 }