Exemplo n.º 1
0
        protected async ETVoid RunAsync(Session session, DBQueryBatchRequest message, Action <DBQueryBatchResponse> reply)
        {
            DBQueryBatchResponse response = new DBQueryBatchResponse();

            try
            {
                DBCacheComponent       dbCacheComponent = Game.Scene.GetComponent <DBCacheComponent>();
                List <ComponentWithId> components       = await dbCacheComponent.GetBatch(message.CollectionName, message.IdList);

                response.Components = components;

                if (message.NeedCache)
                {
                    foreach (ComponentWithId component in components)
                    {
                        dbCacheComponent.AddToCache(component, message.CollectionName);
                    }
                }

                reply(response);
            }
            catch (Exception e)
            {
                ReplyError(response, e, reply);
            }
        }
        protected override async void Run(Session session, DBQueryBatchRequest message, Action <DBQueryBatchResponse> reply)
        {
            DBQueryBatchResponse response = new DBQueryBatchResponse();

            try
            {
                DBCacheComponent dbCacheComponent = Game.Scene.GetComponent <DBCacheComponent>();
                List <Component> disposers        = await dbCacheComponent.GetBatch(message.CollectionName, message.IdList);

                response.Disposers = disposers;

                if (message.NeedCache)
                {
                    foreach (Component disposer in disposers)
                    {
                        dbCacheComponent.AddToCache(disposer, message.CollectionName);
                    }
                }

                reply(response);
            }
            catch (Exception e)
            {
                ReplyError(response, e, reply);
            }
        }
        protected override async ETTask Run(Session session, DBQueryBatchRequest request, DBQueryBatchResponse response, Action reply)
        {
            try
            {
                DBCacheComponent       dbCacheComponent = Game.Scene.GetComponent <DBCacheComponent>();
                List <ComponentWithId> components       = await dbCacheComponent.GetBatch(request.CollectionName, request.IdList);

                response.Components = components;

                if (request.NeedCache)
                {
                    foreach (ComponentWithId component in components)
                    {
                        dbCacheComponent.AddToCache(component, request.CollectionName);
                    }
                }

                reply();

                await ETTask.CompletedTask;
            }
            catch (Exception e)
            {
                ReplyError(response, e, reply);
            }
        }