예제 #1
0
        protected override async void Run(Session session, DBSaveRequest message, Action <DBSaveResponse> reply)
        {
            DBSaveResponse response = new DBSaveResponse();

            try
            {
                DBCacheComponent dbCacheComponent = Game.Scene.GetComponent <DBCacheComponent>();
                if (string.IsNullOrEmpty(message.CollectionName))
                {
                    message.CollectionName = message.Component.GetType().Name;
                }

                if (message.NeedCache)
                {
                    dbCacheComponent.AddToCache(message.Component, message.CollectionName);
                }
                await dbCacheComponent.Add(message.Component, message.CollectionName);

                reply(response);
            }
            catch (Exception e)
            {
                ReplyError(response, e, reply);
            }
        }
예제 #2
0
        protected override async ETTask Run(Session session, DBSaveRequest request, DBSaveResponse response, Action reply)
        {
            try
            {
                DBCacheComponent dbCacheComponent = Game.Scene.GetComponent <DBCacheComponent>();
                if (string.IsNullOrEmpty(request.CollectionName))
                {
                    request.CollectionName = request.Component.GetType().Name;
                }

                if (request.NeedCache)
                {
                    dbCacheComponent.AddToCache(request.Component, request.CollectionName);
                }
                await dbCacheComponent.Add(request.Component, request.CollectionName);

                reply();

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