Exemple #1
0
        /// <summary>
        ///   Initializes a new instance of the <see cref = "HiveGame" /> class.
        /// </summary>
        /// <param name = "gameName">
        ///     The name of the game.
        /// </param>
        /// <param name="roomCache">
        ///     The <see cref="RoomCacheBase"/> instance to which the room belongs.
        /// </param>
        /// <param name="gameStateFactory">Custom factory for GameState. if null is set, default factory is used</param>
        /// <param name="maxEmptyRoomTTL">
        ///     A value indicating how long the room instance will be kept alive 
        ///     in the room cache after all peers have left the room.
        /// </param>
        /// <param name="lastTouchLimitMilliseconds">
        ///     Specifies to maximum value for a peers GetLastTouch in milliseconds before a peer will removed from the room.
        ///     If set to zero no check will bew performed.
        /// </param>
        /// <param name="lastTouchCheckIntervalMilliseconds">
        ///     Specifies the in interval in milliseconds to check peer in the room for the GetLastTouched value.
        ///     If set to zero no check will be performed.
        /// </param>
        /// <param name="executionFiber"></param>
        public HiveGame(string gameName, RoomCacheBase roomCache, IGameStateFactory gameStateFactory = null, 
            int maxEmptyRoomTTL = 0, int lastTouchLimitMilliseconds = 0, int lastTouchCheckIntervalMilliseconds = 0, ExtendedPoolFiber executionFiber = null)
            : base(gameName, executionFiber, roomCache, gameStateFactory, maxEmptyRoomTTL)
        {
            this.ExecutionFiber.Start();

            this.MasterClientId = 0;
            this.IsOpen = true;
            this.IsVisible = true;
            this.LastTouchLimitMilliseconds = lastTouchLimitMilliseconds;
            this.LastTouchCheckIntervalMilliseconds = lastTouchCheckIntervalMilliseconds;

            if (this.LastTouchLimitMilliseconds > 0 && this.LastTouchCheckIntervalMilliseconds > 0)
            {
                this.ExecutionFiber.ScheduleOnInterval(this.CheckPeerStates, this.LastTouchCheckIntervalMilliseconds, this.LastTouchCheckIntervalMilliseconds);
            }

            this.EventCache.SetGameAppCounters(NullHiveGameAppCounters.Instance);
            this.EventCache.Slice = 0;

            this.LogQueue = new LogQueue("Game " + gameName, LogQueue.DefaultCapacity);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="RoomInstance"/> class.
 /// </summary>
 /// <param name="roomFactory">
 /// The room factory.
 /// </param>
 /// <param name="room">
 /// The room.
 /// </param>
 public RoomInstance(RoomCacheBase roomFactory, Room room)
 {
     this.roomFactory = roomFactory;
     this.Room = room;
     this.references = new Dictionary<Guid, RoomReference>();
     this.logQueue = new LogQueue("RoomInstance " + room.Name, LogQueue.DefaultCapacity);
 }