Exemplo n.º 1
0
        private static void updateRoomHome(string name)
        {
            RoomInfoEntity entity = RoomStore.GetRoom(name);

            if (entity != null)
            {
                int num_of_paths = DrawingStore.GetNumberOfPaths(entity.HomeX, entity.HomeY);
                if (num_of_paths < Config.MOVE_HOME_THRESHOLD)
                {
                    return;
                }

#if GO_SLOWER
                num_of_paths = DrawingStore.GetNumberOfPaths(entity.HomeX, entity.HomeY + 1);
                if (num_of_paths < Config.MOVE_HOME_THRESHOLD)
                {
                    return;
                }

                num_of_paths = DrawingStore.GetNumberOfPaths(entity.HomeX, entity.HomeY - 1);
                if (num_of_paths < Config.MOVE_HOME_THRESHOLD)
                {
                    return;
                }
#endif
                if (entity.HomeX < 0)
                {
                    if (entity.HomeY < 0)
                    {
                        entity.HomeX--;
                    }
                    else
                    {
                        entity.HomeY++;
                    }
                }
                else
                if (entity.HomeY < 0)
                {
                    entity.HomeY--;
                }
                else
                {
                    entity.HomeX++;
                }

                Warehouse.RoomsTable.Execute(TableOperation.Replace(entity));                      // Throws StorageException ((412) Precondition Failed) if the entity is modified in between.

                RoomsPond.Notify(name);
            }
        }
Exemplo n.º 2
0
        private static RoomInfo insertNew(string key, string name)
        {
            RoomInfoEntity entity = RoomStore.GetRoom(name);                            // if concurrency happens, this will be done more than once.

            if (entity != null)
            {
                RoomInfo obj = new RoomInfo(entity);

                HttpRuntime.Cache.Insert(key, obj, null, DateTime.Now.AddSeconds(Config.DEFAULT_CACHE_SECONDS),
                                         Cache.NoSlidingExpiration, CacheItemPriority.Default, removedCallback);
                return(obj);
            }
            // expires after some time for multi-node synchronization (unreliable).
            return(null);
        }