Beispiel #1
0
        public void Configuration(IAppBuilder app)
        {
            var config = new HttpConfiguration();
            var container = CreateKernel();

            _backgroundTicker = new BackgroundTicker(container.Resolve<IHubMessageService>());

            app.UseAutofacMiddleware(container).UseAutofacWebApi(config);
            app.MapSignalR();
            WebApiConfig.Register(config);
            app.UseWebApi(config);

            var physicalFileSystem = new PhysicalFileSystem(@"..");
            var options = new FileServerOptions
            {
                EnableDefaultFiles = true,
                FileSystem = physicalFileSystem
            };
            options.StaticFileOptions.FileSystem = physicalFileSystem;
            options.StaticFileOptions.ServeUnknownFileTypes = true;
            options.DefaultFilesOptions.DefaultFileNames = new[]
            {
                "index.html"
            };

            app.UseFileServer(options);

            ActorSystem StatsActorSystem = container.Resolve<IActorSystemFactory>().Create("StatsCoordinatorActor");
            MongoDbPersistence.Instance.Apply(StatsActorSystem);
            BsonClassMap.RegisterClassMap<CreateHitterMessage>(cm =>
            {
                cm.AutoMap();
            });
            BsonClassMap.RegisterClassMap<HitHomeRunMessage>(cm =>
            {
                cm.AutoMap();
            });

            BsonClassMap.RegisterClassMap<HomeRunHitEvent>(cm =>
            {
                cm.AutoMap();
            });
            BsonClassMap.RegisterClassMap<HitterAddedEvent>(cm =>
            {
                cm.AutoMap();
            });

            StatsActors stats = container.Resolve<StatsActors>();
            stats.statActorRef = StatsActorSystem.ActorOf(StatsActorSystem.DI().Props<StatsCoordinatorActor>()
                .WithRouter(new RoundRobinPool(2)), "StatsCoordinatorActor");
            stats.statCommandActorRef = StatsActorSystem.ActorOf(StatsActorSystem.DI().Props<StatsCoordinatorCommandActor>(), "StatsCoordinatorCommandActor");
            stats.statViewActorRef = StatsActorSystem.ActorOf(StatsActorSystem.DI().Props<StatsCoordinatorViewActor>(), "StatsCoordinatorViewActor");
        }
Beispiel #2
0
        public void Configuration(IAppBuilder app)
        {
            var config = new HttpConfiguration();
            var container = CreateKernel();

            _backgroundTicker = new BackgroundTicker(container.Resolve<IHubMessageService>());

            app.UseAutofacMiddleware(container).UseAutofacWebApi(config);
            app.MapSignalR();
            WebApiConfig.Register(config);
            app.UseWebApi(config);
        }