Example #1
0
        public ETTask <IResponse> Call(IRequest request)
        {
            int rpcId = ++RpcId;
            var tcs   = new ETTaskCompletionSource <IResponse>();

            this.requestCallback[rpcId] = (response) =>
            {
                if (response is ErrorResponse)
                {
                    tcs.SetException(new Exception($"Rpc error: {MongoHelper.ToJson(response)}"));
                    return;
                }

                if (ErrorCode.IsRpcNeedThrowException(response.Error))
                {
                    tcs.SetException(new Exception($"Rpc error: {MongoHelper.ToJson(response)}"));
                    return;
                }

                tcs.SetResult(response);
            };

            request.RpcId = rpcId;
            this.Send(request);
            return(tcs.Task);
        }
Example #2
0
        public void Run()
        {
            ETTaskCompletionSource tcs = this.Callback;

            this.GetParent <TimerComponent>().Remove(this.Id);
            tcs.SetResult();
        }
Example #3
0
        public void Update()
        {
            if (!this.request.isDone)
            {
                return;
            }

            ETTaskCompletionSource t = tcs;

            t.SetResult();
        }
Example #4
0
        public void Update()
        {
            if (!this.request.isDone)
            {
                return;
            }

            ETTaskCompletionSource <AssetBundle> t = tcs;

            t.SetResult(this.request.assetBundle);
        }
Example #5
0
        public void Notify(CoroutineLockType coroutineLockType, long key)
        {
            CoroutineLockQueueType coroutineLockQueueType = this.list[(int)coroutineLockType];

            if (!coroutineLockQueueType.TryGetValue(key, out CoroutineLockQueue queue))
            {
                throw new Exception($"first work notify not find queue");
            }
            if (queue.Count == 0)
            {
                coroutineLockQueueType.Remove(key);
                queue.Dispose();
                return;
            }

            ETTaskCompletionSource <CoroutineLock> tcs = queue.Dequeue();

            tcs.SetResult(EntityFactory.CreateWithParent <CoroutineLock, CoroutineLockType, long>(this, coroutineLockType, key));
        }
Example #6
0
        public void Update()
        {
            if (this.moveTcs == null)
            {
                return;
            }

            Unit unit    = this.GetParent <Unit>();
            long timeNow = TimeHelper.Now();

            if (timeNow - this.StartTime >= this.needTime)
            {
                unit.Position = this.Target;
                ETTaskCompletionSource tcs = this.moveTcs;
                this.moveTcs = null;
                tcs.SetResult();
                return;
            }

            float amount = (timeNow - this.StartTime) * 1f / this.needTime;

            unit.Position = Vector3.Lerp(this.StartPos, this.Target, amount);
        }