Exemple #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RoomReference"/> class.
 /// </summary>
 /// <param name="roomCache">
 /// The room cache.
 /// </param>
 /// <param name="room">
 /// The room.
 /// </param>
 /// <param name="ownerPeer">
 /// An <see cref="PeerBase"/> instance which obtained the room reference.
 /// </param>
 public RoomReference(RoomCacheBase roomCache, Room room, PeerBase ownerPeer)
 {
     this.roomCache = roomCache;
     this.id        = Guid.NewGuid();
     this.Room      = room;
     this.ownerPeer = ownerPeer;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="RoomReference"/> class.
 /// </summary>
 /// <param name="roomCache">
 /// The room cache.
 /// </param>
 /// <param name="room">
 /// The room.
 /// </param>
 /// <param name="ownerPeer">
 /// An <see cref="PeerBase"/> instance which obtained the room reference.
 /// </param>
 public RoomReference(RoomCacheBase roomCache, Room room, PeerBase ownerPeer)
 {
     this.roomCache = roomCache;
     this.id = Guid.NewGuid();
     this.Room = room;
     this.ownerPeer = ownerPeer;
 }
Exemple #3
0
 /// <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);
 }
        public HiveHostGame(
            string gameName,
            RoomCacheBase roomCache,
            IGameStateFactory gameStateFactory = null,
            int maxEmptyRoomTTL = 0,
            IPluginManager pluginManager = null,
            string pluginName = "",
            Dictionary<string, object> environment = null,
            int lastTouchLimitMilliseconds = 0,
            int lastTouchCheckIntervalMilliseconds = 0,
            HttpRequestQueueOptions httpRequestQueueOptions = null,
            ExtendedPoolFiber executionFiber = null
            )
            : base(gameName, roomCache, gameStateFactory, maxEmptyRoomTTL, lastTouchLimitMilliseconds, lastTouchCheckIntervalMilliseconds, executionFiber)
        {
            this.pluginManager = pluginManager;

            if (httpRequestQueueOptions == null)
            {
                httpRequestQueueOptions = new HttpRequestQueueOptions();
            }

            this.httpRequestQueue.MaxErrorRequests = httpRequestQueueOptions.HttpQueueMaxTimeouts;
            this.httpRequestQueue.MaxTimedOutRequests = httpRequestQueueOptions.HttpQueueMaxErrors;
            this.httpRequestQueue.ReconnectInterval = TimeSpan.FromMilliseconds(httpRequestQueueOptions.HttpQueueReconnectInterval);
            this.httpRequestQueue.QueueTimeout = TimeSpan.FromMilliseconds(httpRequestQueueOptions.HttpQueueQueueTimeout);
            this.httpRequestQueue.MaxQueuedRequests = httpRequestQueueOptions.HttpQueueMaxQueuedRequests;
            this.httpRequestQueue.MaxBackoffInMilliseconds = httpRequestQueueOptions.HttpQueueMaxBackoffTime;
            this.httpRequestQueue.MaxConcurrentRequests = httpRequestQueueOptions.HttpQueueMaxConcurrentRequests;

            this.httpQueueRequestTimeout = httpRequestQueueOptions.HttpQueueRequestTimeout;

            this.httpRequestQueue.SetCounters(this);

            this.Environment = environment ?? new Dictionary<string, object>
                                       {
                                           {"AppId", GetHwId()},
                                           {"AppVersion", ""},
                                           {"Region", ""},
                                           {"Cloud", ""},
                                       };
            this.InitPlugin(pluginName);
            if (this.Plugin == null)
            {
                throw new Exception(string.Format("Failed to craete plugin '{0}'", pluginName));
            }

            var errorPlugin = this.Plugin as ErrorPlugin;
            if (errorPlugin != null)
            {
                Log.ErrorFormat("Game {0} is created with ErrorPlugin. message:{1}", this.Name, errorPlugin.Message);
            }

            this.customTypeCache.TypeMapper = this;
            this.callEnv = new CallEnv(this.Plugin, this.Name);
        }
Exemple #5
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);
        }
Exemple #6
0
 /// <summary>
 ///   Initializes a new instance of the <see cref = "Room" /> class without a room name.
 /// </summary>
 /// <param name = "name">
 ///   The room name.
 /// </param>
 /// <param name="roomCache">
 ///   The <see cref="RoomCacheBase"/> instance to which the room belongs.
 /// </param>
 /// <param name="gameStateFactory">Fatory for game state</param>
 /// <param name="maxEmptyRoomTTL">
 ///   A value indicating how long the room instance will be keeped alive 
 ///   in the room cache after all peers have left the room.
 /// </param>
 /// <param name="executionFiber">Fiber which will execute rooms actions</param>
 public Room(string name, RoomCacheBase roomCache = null, IGameStateFactory gameStateFactory = null, int maxEmptyRoomTTL = 0, ExtendedPoolFiber executionFiber = null)
     : this(name, executionFiber, roomCache, gameStateFactory, maxEmptyRoomTTL)
 {
     this.ExecutionFiber.Start();
     RemoveRoomPath = RemoveState.Alive;
 }
Exemple #7
0
        /// <summary>
        ///   Initializes a new instance of the <see cref = "Room" /> class.
        /// </summary>
        /// <param name = "name">
        ///   The room name.
        /// </param>
        /// <param name = "executionFiber">
        ///   The execution fiber used to synchronize access to this instance.
        /// </param>
        /// <param name="roomCache">
        ///   The <see cref="RoomCacheBase"/> instance to which the room belongs.
        /// </param>
        /// <param name="gameStateFactory">Fatory for game state</param>
        /// <param name="maxEmptyRoomTTL">
        ///   A value indicating how long the room instance will be keeped alive 
        ///   in the room cache after all peers have left the room.
        /// </param>
        protected Room(string name, ExtendedPoolFiber executionFiber, RoomCacheBase roomCache, IGameStateFactory gameStateFactory = null, int maxEmptyRoomTTL = 0)
        {
            this.name = name;

            this.gameStateFactory = gameStateFactory ?? defaultFactory;
            this.roomState = this.gameStateFactory.Create();
            this.ExecutionFiber = executionFiber ?? new ExtendedPoolFiber();

            this.roomCache = roomCache;
            this.MaxEmptyRoomTTL = maxEmptyRoomTTL;
        }
 /// <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);
 }
Exemple #9
0
 public TestGame(GameApplication application, string gameId, RoomCacheBase roomCache = null, 
     IPluginManager pluginManager = null, string pluginName = "", Dictionary<string, object> environment = null)
     : base(application, gameId, roomCache, pluginManager, pluginName, environment)
 {
 }