Пример #1
0
        public void StartInstance(GameData gameData, bool waitForEnd)
        {
            var instance = new ScriptedGameInstance(this, gameData, externalGameUrl, externalGameSSLUrl, GetInstanceSettings(gameData), accountingFacadeFactory.CreateFacade(), reportTracker);

            instance.Start();
            if (waitForEnd)
            {
                instance.WaitReady();
            }
        }
Пример #2
0
        public DelayedTask(ScriptedGameInstance gameInstance, ScriptedGameContext context, JavascriptContext javascriptContext, string id, object jsFunction, double period)
        {
            if (double.IsNaN(period))
            {
                throw new InvalidOperationException("Cannot initialize delayed task with NaN delay");
            }

            this.gameInstance      = gameInstance;
            this.context           = context;
            this.javascriptContext = javascriptContext;
            this.id         = id;
            this.jsFunction = jsFunction;
            executionTime   = DateTime.Now.Add(TimeSpan.FromMilliseconds(period));
        }
Пример #3
0
        public void NotifyIstanceRenamed(string oldName, ScriptedGameInstance gameInstance)
        {
            MonitoringFacade.UnregisterMonitoringSource(oldName);
            MonitoringFacade.RegisterMonitoringSource(gameInstance.Name);

            if (OnUnRegisterInstance != null)
            {
                OnUnRegisterInstance(gameInstance, new ScriptedGameWrapperEventArgs(oldName));
            }

            if (OnRegisterInstance != null)
            {
                OnRegisterInstance(gameInstance, new ScriptedGameWrapperEventArgs(gameInstance.Id));
            }
        }
Пример #4
0
        public void NotifyIstanceAdded(ScriptedGameInstance gameInstance)
        {
            lock (instanceLock)
            {
                instanceCount++;
                gameInstances.Add(gameInstance);
            }

            MonitoringFacade.RegisterMonitoringSource(gameInstance.Name);

            if (OnRegisterInstance != null)
            {
                OnRegisterInstance(gameInstance, new ScriptedGameWrapperEventArgs(gameInstance.Id));
            }
        }
Пример #5
0
 public ScriptedGameContext(ScriptedGameInstance game, JavascriptContext javascriptContext, GameData gameData, GameInstanceConfiguration instanceConfiguration, object gameConfiguration, IDictionary <string, object> vodData, IDictionary <string, object> virtualData, IDictionary <string, object> streamConfig, bool hasLiveStreams, IAccountingFacade accountingFacade, ILiveReportTracker reportTracker)
 {
     this.game = game;
     this.javascriptContext    = javascriptContext;
     this.gameData             = gameData;
     gameInstanceConfiguration = instanceConfiguration;
     gameSpecificConfiguration = gameConfiguration;
     this.reportTracker        = reportTracker;
     this.accountingFacade     = accountingFacade;
     mediaHelper      = new GameMediaHelper(this, vodData, virtualData, streamConfig, hasLiveStreams);
     storageHelper    = new StorageHelper(game.IdLong.ToString(), this);
     rng              = new RNGWrapper(this, null);
     roundCounter     = new RoundCounter(this);
     accountingHelper = new AccountingHelper(this, accountingFacade, reportTracker, instanceConfiguration.TrackFunData);
 }
Пример #6
0
        public void InitializeInstances()
        {
            if (isDisposed)
            {
                return;
            }

            Log(Id, "Initializing game instances...");

            var games = ExternalServiceFacade.GetGameCoreService().GetGames(gameTypeEntity.Id);

            foreach (var game in games)
            {
                var instance = new ScriptedGameInstance(this, game, externalGameUrl, externalGameSSLUrl, GetInstanceSettings(game), accountingFacadeFactory.CreateFacade(), reportTracker);
                instance.Start();
            }
        }
Пример #7
0
        public void NotifyIstanceRemoved(ScriptedGameInstance gameInstance)
        {
            lock (instanceLock)
            {
                instanceCount--;
                if (gameInstances.Contains(gameInstance))
                {
                    gameInstances.Remove(gameInstance);
                }
            }

            try
            {
                if (OnUnRegisterInstance != null)
                {
                    OnUnRegisterInstance(gameInstance, new ScriptedGameWrapperEventArgs(gameInstance.Id));
                }
            }
            catch (Exception ex)
            {
                Logger.Log(ex);
            }
        }