Beispiel #1
0
        protected override void OnStart()
        {
            base.OnStart();

            _logicHandler.Start();

            _gamePlayEngine.Subscribe(_gameEngineListener);

            _gamePlayEngine.Start();
        }
        protected override void OnStart()
        {
            base.OnStart();

            _readCacheDataRepository.Start();
            _gameDataRepository.Start();

            _logicHandler.Start();

            _gamePlayEngine.Subscribe(_gamePlayListener);

            _gamePlayEngine.Start();
        }
        protected override void OnStart()
        {
            // Update some basic settings
            _appSettings.AddOrUpdate(CommonAppSettingsKeys.ClientIdSetting.Name, Guid.NewGuid().ToString());
            _appSettings.AddOrUpdate(CommonAppSettingsKeys.ClientNameSetting.Name, "CQRS Service");

            // Start dependent components
            _eventPublisher.Start();
            _logicHandler.Start();

            // Get a TCP port that is available
            var portReservation = _localTcpPortManager.GetNextAvailablePort();

            var hostPort = portReservation.Port;
            var sslPort  = portReservation.Port + 1;

            // Update the local setting to begin hosting with the port
            _appSettings.AddOrUpdate(CommonAppSettingsKeys.HttpHostPortSetting.Name, portReservation.Port.ToString());


            try
            {
                // Expose API endpoint
                if (_webHost.IsNotNull())
                {
                    _webHost.Dispose();
                }

                var builder = WebHost.CreateDefaultBuilder();

                //
                _hostUri = new UriBuilder(
                    "https",
                    "localhost",
                    sslPort
                    ).Uri;

                builder.UseKestrel(options =>
                {
                    options.Listen(IPAddress.Loopback, hostPort);
                    options.Listen(IPAddress.Loopback, sslPort, listenOptions =>
                    {
                        listenOptions.UseHttps(StoreName.My, "localhost");
                    });
                }
                                   );

                builder.ConfigureServices(ConfigureServices);
                builder.Configure(Configure);

                _webHost = builder.Build();

                try
                {
                    _webHost.Start();
                }
                catch (Exception ex)
                {
                    _log.Error(ex, ex.Message);

                    throw;
                }
            }
            finally
            {
                portReservation.Dispose();
            }

            _log.InfoFormat(
                "Listening on: http://localhost:{0}/ and https://localhost:{1}/",
                hostPort,
                sslPort
                );
        }