Ejemplo n.º 1
0
        public async System.Threading.Tasks.Task <R> DoAwaitCall(T arg, long timeOut,
                                                                 NetCore.ERouteTarget route = NetCore.ERouteTarget.Self,
                                                                 NetCore.NetConnection conn = null,
                                                                 NetCore.RPCRouter router   = null,
                                                                 byte userFlags             = 0)
        {
            if (conn == null)
            {
                conn = RPCProcessor.DefaultConnection;
            }
            var pkg = new NetCore.PkgWriter(arg.GetPkgSize());

            pkg.SetUserFlags(userFlags);
            RPCExecuter.RPCWait waiter = null;
            try
            {
                waiter = WritePkgHeader <T>(ref pkg, ref arg, timeOut, RPCAwaiter.NullCB, route, conn, router);

                OnWriteArugment(ref arg, ref pkg);

                if (conn != null)
                {
                    pkg.SendBuffer(conn);
                }
            }
            finally
            {
                pkg.Dispose();
            }

            waiter.Processor = this;
            var result = await RPCAwaiter.RPCWaitReturn <R>(waiter);

            return(result);
        }
Ejemplo n.º 2
0
        public async Task <T> S2S_AwaitCall <T>(long timeOut, ERouteTarget target = ERouteTarget.Data) where T : RPCReturnValue, new()
        {
            AssertReturnType(this.GetType(), typeof(T));

            RPCExecManager.RPCWait writer = null;
            if (timeOut == 0)
            {
                writer = WaitDoCallImpl(timeOut, null, ERouteTarget.Self, RPCExecManager.Insance.GetServerConnect(target));
            }
            else
            {
                writer = WaitDoCallImpl(timeOut, RPCAwaiter.NullCB, ERouteTarget.Self, RPCExecManager.Insance.GetServerConnect(target));
            }

            var result = await RPCAwaiter.RPCWaitReturn <T>(writer);

            return(result);
        }
Ejemplo n.º 3
0
        public async Task <T> C2S_AwaitCall <T>(long timeOut, ERouteTarget route = ERouteTarget.Hall) where T : RPCReturnValue, new()
        {
            AssertReturnType(this.GetType(), typeof(T));
            if (route == ERouteTarget.Gate)
            {
                route = ERouteTarget.Self;
            }

            RPCExecManager.RPCWait waiter = null;
            if (timeOut == 0)
            {
                waiter = WaitDoCallImpl(0, null, route, RPCExecManager.Insance.C2SConnect);
            }
            else
            {
                waiter = WaitDoCallImpl(timeOut, RPCAwaiter.NullCB, route, RPCExecManager.Insance.C2SConnect);
            }

            var result = await RPCAwaiter.RPCWaitReturn <T>(waiter);

            return(result);
        }
Ejemplo n.º 4
0
        public async Task <T> AwaitHashCall <T>(long timeOut, ERouteTarget route = ERouteTarget.Self,
                                                Net.NetConnection conn           = null,
                                                RPCRouter router = null) where T : RPCReturnValue, new()
        {
            AssertReturnType(this.GetType(), typeof(T));
            RPCExecManager.RPCWait pkg = null;
            if (timeOut == 0)
            {
                pkg = WaitDoCallImpl_Hash(timeOut, null, route, conn, router);
            }
            else
            {
                pkg = WaitDoCallImpl_Hash(timeOut, RPCAwaiter.NullCB, route, conn, router);
            }

            var result = await RPCAwaiter.RPCWaitReturn <T>(pkg);

            if (result == null)
            {
                System.Diagnostics.Debug.WriteLine($"RPC Time Out: {this.GetType().FullName}");
                return(null);
            }
            return(result);
        }
Ejemplo n.º 5
0
        public static async Task <T> RPCWaitReturn_Unmanaged <T>(RPCExecuter.RPCWait waiter) where T : unmanaged, IReturnValue
        {
            T rt = await RPCAwaiter.AsyncTask().RPCWaitReturn_Unmanaged <T>(waiter);

            return(rt);
        }
Ejemplo n.º 6
0
 public void OnCompleted(Action continuation)
 {
     RPCAwaiter.PushContinueAction_Unmanaged <T>(continuation, this);
 }
Ejemplo n.º 7
0
        public static async Task <T> RPCWaitReturn <T>(RPCExecuter.RPCWait waiter) where T : struct, IReturnValue
        {
            T rt = await RPCAwaiter.AsyncTask().RPCWaitReturn <T>(waiter);

            return(rt);
        }
Ejemplo n.º 8
0
 public void OnCompleted(Action continuation)
 {
     RPCAwaiter.PushContinueAction <T>(continuation, this);
     // ContinueWith sets the scheduler to use for the continuation action
     //task.ContinueWith(x => continuation(), scheduler);
 }