Ejemplo n.º 1
0
        public void Configuration(IAppBuilder app)
        {
            ConfigureAuth(app);

            var kernel   = NinjectWebCommon.bootstrapper.Kernel;
            var resolver = new NinjectSignalRDependencyResolver(kernel);

            // Binding Orders Hub to Orders Bridge
            kernel.Bind(typeof(IHubConnectionContext <dynamic>))
            .ToMethod(context => resolver
                      .Resolve <IConnectionManager>()
                      .GetHubContext <OrdersHub>()
                      .Clients)
            .WhenInjectedInto <IOrderBridge>();

            // Binding Taxies Hub to Taxies Bridge
            kernel.Bind(typeof(IHubConnectionContext <dynamic>))
            .ToMethod(context => resolver
                      .Resolve <IConnectionManager>()
                      .GetHubContext <TaxiesHub>()
                      .Clients)
            .WhenInjectedInto <ITaxiesBridge>();

            var config = new HubConfiguration();

            config.Resolver = resolver;
            ConfigureSignalR(app, config);
        }
Ejemplo n.º 2
0
        public void Configuration(IAppBuilder app)
        {
            // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=316888

            var kernel   = new StandardKernel();
            var resolver = new NinjectSignalRDependencyResolver(kernel);

            kernel.Bind <IExecutiveDashboadTicker>().To <ExecutiveDashboardTicker>().InSingletonScope();//Bind to Executive Ticker object  // Make it a singleton object.

            kernel.Bind(typeof(IHubConnectionContext <dynamic>)).ToMethod(context =>
                                                                          resolver.Resolve <IConnectionManager>().GetHubContext <ExecutiveDashboardHub>().Clients)
            .WhenInjectedInto <IExecutiveDashboadTicker>();



            kernel.Bind <IYakkrTicker>().To <YakkrTicker>().InSingletonScope();

            kernel.Bind(typeof(IHubConnectionContext <dynamic>)).ToMethod(context =>
                                                                          resolver.Resolve <IConnectionManager>().GetHubContext <YakkrHub>().Clients
                                                                          ).WhenInjectedInto <IYakkrTicker>();

            var config = new HubConfiguration();

            config.Resolver = resolver;


            ConfigureAuth(app);

            ConfigureSignalR(app, config);
        }
Ejemplo n.º 3
0
        public void Configuration(IAppBuilder app)
        {
            var kernel   = new StandardKernel();
            var resolver = new NinjectSignalRDependencyResolver(kernel);

            kernel.Bind <IFirebaseListener>()
            .To <FirebaseListener>()
            .InSingletonScope();

            kernel.Bind(typeof(IHubConnectionContext <dynamic>)).ToMethod(context =>
                                                                          resolver.Resolve <IConnectionManager>().GetHubContext <PushHub>().Clients
                                                                          ).WhenInjectedInto <IFirebaseListener>();

            kernel.Bind <FirebaseApp>()
            .ToConstructor((a) => new FirebaseApp(new Uri("https://fir-poc-fe6af.firebaseio.com/"), null));

            // Forçar inicialização
            kernel.Get <IFirebaseListener>();

            var config = new HubConfiguration();

            config.Resolver = resolver;

            app.MapSignalR(config);

            var kernelConnection   = new StandardKernel();
            var resolverConnection = new NinjectSignalRDependencyResolver(kernel);

            kernelConnection.Bind <IFirebaseListener>()
            .To <FirebaseListener>()
            .InSingletonScope();

            kernelConnection.Bind(typeof(IConnection)).ToMethod(context =>
                                                                resolver.Resolve <IConnectionManager>().GetConnectionContext <PushConnection>().Connection
                                                                ).WhenInjectedInto <IFirebaseListener>();

            kernelConnection.Bind <FirebaseApp>()
            .ToConstructor((a) => new FirebaseApp(new Uri("https://fir-poc-fe6af.firebaseio.com/"), null));

            // Forçar inicialização
            kernelConnection.Get <IFirebaseListener>();

            app.MapSignalR <PushConnection>("/TestConnection", new ConnectionConfiguration()
            {
                Resolver = resolverConnection
            });
        }
Ejemplo n.º 4
0
        private static void SetupSignalR(IJabbrConfiguration jabbrConfig, IKernel kernel, IAppBuilder app)
        {
            var resolver          = new NinjectSignalRDependencyResolver(kernel);
            var connectionManager = resolver.Resolve <IConnectionManager>();
            var heartbeat         = resolver.Resolve <ITransportHeartbeat>();
            var hubPipeline       = resolver.Resolve <IHubPipeline>();
            var configuration     = resolver.Resolve <IConfigurationManager>();

            // Enable service bus scale out
            if (!String.IsNullOrEmpty(jabbrConfig.ServiceBusConnectionString) &&
                !String.IsNullOrEmpty(jabbrConfig.ServiceBusTopicPrefix))
            {
                var sbConfig = new ServiceBusScaleoutConfiguration(jabbrConfig.ServiceBusConnectionString,
                                                                   jabbrConfig.ServiceBusTopicPrefix)
                {
                    TopicCount = 5
                };

                resolver.UseServiceBus(sbConfig);
            }

            if (jabbrConfig.ScaleOutSqlServer)
            {
                resolver.UseSqlServer(ConfigurationManager.ConnectionStrings["Jabbr"].ConnectionString);
            }

            kernel.Bind <IConnectionManager>()
            .ToConstant(connectionManager);

            // We need to extend this since the inital connect might take a while
            configuration.TransportConnectTimeout = TimeSpan.FromSeconds(30);

            var config = new HubConfiguration
            {
                Resolver = resolver
            };

            hubPipeline.AddModule(kernel.Get <LoggingHubPipelineModule>());

            app.MapSignalR(config);

            var monitor = new PresenceMonitor(kernel, connectionManager, heartbeat);

            monitor.Start();
        }
Ejemplo n.º 5
0
        public void Configuration(IAppBuilder app)
        {
            var kernel = new StandardKernel();
            var resolver = new NinjectSignalRDependencyResolver(kernel);

            DependencyResolver.DependencyResolver.Resolve(kernel);

            kernel.Bind(typeof (IHubConnectionContext<dynamic>)).ToMethod(context =>
                resolver.Resolve<IConnectionManager>().GetHubContext<ChatHub>().Groups
                ).WhenInjectedInto<Chat>();
            kernel.Bind(typeof (IHubConnectionContext<dynamic>)).ToMethod(context =>
                resolver.Resolve<IConnectionManager>().GetHubContext<ChatHub>().Groups
                ).WhenInjectedInto<UserService>();
            kernel.Bind(typeof (IHubConnectionContext<dynamic>)).ToMethod(context =>
                resolver.Resolve<IConnectionManager>().GetHubContext<ChatHub>().Groups
                ).WhenInjectedInto<MessageService>();

            var config = new HubConfiguration { Resolver = resolver };
            ConfigureSignalR(app, config);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// When using WebApp.Start, this is called by convention.
        /// </summary>
        /// <param name="myApp"></param>
        public void Configuration(IAppBuilder myApp)
        {
            Log.Debug("Startup configuration");

            try
            {
                // Enable cross-site access
                myApp.UseCors(CorsOptions.AllowAll);

                Log.Debug("Create Ninject kernel");
                var kernel = new StandardKernel();

                kernel.Bind<IExcelSessionManager>()
                      .To<ExcelSessionManager>()
                      .InSingletonScope();
                kernel.Bind<ILog>()
                      .To<Log4NetLogger>()
                      .WithConstructorArgument(typeof (Type), c => c.Request.ParentRequest.Service);
                

                Log.Debug("Configure WebAPI");
                var config = new HttpConfiguration {DependencyResolver = new NinjectResolver(kernel)};
                config.MapHttpAttributeRoutes();
                config.Routes.MapHttpRoute("ExcelServiceApi", "excel/{controller}/{id}",
                                           new {id = RouteParameter.Optional});
                myApp.UseWebApi(config);

                Log.Debug("Configure SignalR");
                var resolver = new NinjectSignalRDependencyResolver(kernel);
                GlobalHost.DependencyResolver = resolver;

                kernel.Bind(typeof(IHubContext)).ToMethod(context =>resolver.Resolve<IConnectionManager>().GetHubContext<ExcelHub>()).WhenInjectedInto(new[]{typeof(ApiController), typeof(ExcelSessionManager)});

                
                myApp.MapSignalR();
            }
            catch (Exception ex)
            {
                Log.ErrorFormat("Error on startup configuration: {0}", ex.Message);

                var currEx = ex.InnerException;
                while (currEx != null)
                {
                    Log.Error(currEx.Message);
                    currEx = currEx.InnerException;
                }
            }

            Log.Debug("Finished startup configuration");
        }
Ejemplo n.º 7
0
        private static void SetupSignalR(IKernel kernel, IAppBuilder app)
        {
            var resolver          = new NinjectSignalRDependencyResolver(kernel);
            var connectionManager = resolver.Resolve <IConnectionManager>();
            var heartbeat         = resolver.Resolve <ITransportHeartbeat>();
            var hubPipeline       = resolver.Resolve <IHubPipeline>();

            kernel.Bind <IConnectionManager>()
            .ToConstant(connectionManager);

            var config = new HubConfiguration
            {
                Resolver = resolver
            };

            hubPipeline.AddModule(kernel.Get <LoggingHubPipelineModule>());

            app.MapSignalR(config);

            var monitor = new PresenceMonitor(kernel, connectionManager, heartbeat);

            monitor.Start();
        }
Ejemplo n.º 8
0
        // Any connection or hub wire up and configuration should go here
        public void Configuration(IAppBuilder app)
        {
            var kernel = new StandardKernel();
            var resolver = new NinjectSignalRDependencyResolver(kernel);

            kernel.Bind<IChatRepository>()
                .To<CloudStorage>()  // Bind to CloudStorage.
                .InSingletonScope();  // Make it a singleton object.

            kernel.Bind(typeof(IHubConnectionContext<dynamic>)).ToMethod(context =>
                    resolver.Resolve<IConnectionManager>().GetHubContext<ChatHub>().Clients
                        ).WhenInjectedInto<IChatRepository>();

            var config = new HubConfiguration {Resolver = resolver};
            ConfigureSignalR(app, config);
        }
Ejemplo n.º 9
0
        private static void SetupSignalR(IKernel kernel, IAppBuilder app)
        {
            var resolver          = new NinjectSignalRDependencyResolver(kernel);
            var connectionManager = resolver.Resolve <IConnectionManager>();

            kernel.Bind <IConnectionManager>()
            .ToConstant(connectionManager);

            var config = new HubConfiguration
            {
                Resolver             = resolver,
                EnableDetailedErrors = true
            };

            app.MapHubs(config);

            StartBackgroundWork(kernel, resolver);
        }
Ejemplo n.º 10
0
        private static void SetupSignalR(IKernel kernel, IAppBuilder app)
        {
            var resolver = new NinjectSignalRDependencyResolver(kernel);
            var connectionManager = resolver.Resolve<IConnectionManager>();

            kernel.Bind<IConnectionManager>()
                  .ToConstant(connectionManager);

            var config = new HubConfiguration
            {
                Resolver = resolver,
                EnableDetailedErrors = true
            };

            app.MapHubs(config);

            StartBackgroundWork(kernel, resolver);
        }
Ejemplo n.º 11
0
        public void Configuration(IAppBuilder app)
        {
            if (kernel == null)
            {
                throw new InvalidOperationException("Ninject kernel must be set first.");
            }

            var settings = new JsonSerializerSettings
            {
                ContractResolver = new SelectiveCamelCaseContractResolver(),
                Converters = { new StringEnumConverter() },
            };

            var jsonNetSerializer = JsonSerializer.Create(settings);

            var resolver = new NinjectSignalRDependencyResolver(kernel);
            resolver.Register(typeof(JsonSerializer), () => jsonNetSerializer);

            var hubConfiguration = new HubConfiguration
            {
                EnableDetailedErrors = NuGetWebApiModule.ShowExceptionDetails,
                EnableJSONP = NuGetWebApiModule.EnableCrossDomainRequests,
                Resolver = resolver
            };

            app.Map("/" + NuGetWebApiModule.RoutePathPrefix + "signalr", map =>
            {
                if (NuGetWebApiModule.EnableCrossDomainRequests)
                {
                    map.UseCors(CorsOptions.AllowAll);
                }
                map.RunSignalR(hubConfiguration);
            });

            var connectionManager = resolver.Resolve<IConnectionManager>();

            var hub = connectionManager.GetHubContext<StatusHub>();

            var repository = kernel.Get<ILucenePackageRepository>();

            repository.StatusChanged
                .Sample(TimeSpan.FromMilliseconds(250))
                .Subscribe(status => hub.Clients.All.updateStatus(status));
        }
Ejemplo n.º 12
0
            public void Configuration(IAppBuilder app)
            {
                var kernel = new StandardKernel();
                var resolver = new NinjectSignalRDependencyResolver(kernel);

                kernel.Bind<IForecastingDataBroadcaster>()
                      .To<ForecastingDataBroadcaster>()
                      .InSingletonScope();

                kernel.Bind<IHubConnectionContext>().ToMethod(context =>
                                                              resolver.Resolve<IConnectionManager>().
                                                                       GetHubContext<ForecastingDataHub>().Clients
                    ).WhenInjectedInto<IForecastingDataBroadcaster>();

                kernel.Bind<DbContext>()
                      .To<ForecastContext>()
                      .InSingletonScope();

                kernel.Bind<IRepository>()
                     .To<EntityFrameworkRepository>()
                     .InSingletonScope();

                //setup data directory
                AppDomain.CurrentDomain.SetData("DataDirectory", Directory.GetCurrentDirectory());

                var signalRConfig = new HubConfiguration
                {
                    EnableCrossDomain = true,
                    EnableDetailedErrors = true,
                    Resolver = resolver
                };

                app.MapHubs(signalRConfig);

                var webAPIConfig = new HttpConfiguration();
                webAPIConfig.Routes.MapHttpRoute(
                    name: "DefaultApi",
                    routeTemplate: "api/{controller}/{period}"
                    );

                app.UseWebApi(webAPIConfig);
            }
Ejemplo n.º 13
0
    public void Configuration(IAppBuilder app)
    {
        // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=316888

        var kernel   = new StandardKernel();
        var resolver = new NinjectSignalRDependencyResolver(kernel);

        kernel.Bind <IStockTicker>()
        .To <Microsoft.AspNet.SignalR.StockTicker.StockTicker>() // Bind to StockTicker.
        .InSingletonScope();                                     // Make it a singleton object.

        kernel.Bind(typeof(IHubConnectionContext <dynamic>)).ToMethod(context =>
                                                                      resolver.Resolve <IConnectionManager>().GetHubContext <StockTickerHub>().Clients
                                                                      ).WhenInjectedInto <IStockTicker>();

        var config = new HubConfiguration();

        config.Resolver = resolver;
        Microsoft.AspNet.SignalR.StockTicker.Startup.ConfigureSignalR(app, config);
    }
Ejemplo n.º 14
0
    public static void Start()
    {
        var kernel   = new StandardKernel();
        var resolver = new NinjectSignalRDependencyResolver(kernel);

        kernel.Bind <IStockTicker>()
        .To <Microsoft.AspNet.SignalR.StockTicker.StockTicker>()
        .InSingletonScope();

        kernel.Bind <IHubConnectionContext>().ToMethod(context =>
                                                       resolver.Resolve <IConnectionManager>().
                                                       GetHubContext <StockTickerHub>().Clients
                                                       ).WhenInjectedInto <IStockTicker>();

        var config = new HubConfiguration()
        {
            Resolver = resolver
        };

        // Register the default hubs route: ~/signalr/hubs
        RouteTable.Routes.MapHubs(config);
    }
        public static void ConfigureSignalR(IAppBuilder app)
        {
            var kernel   = new StandardKernel();
            var resolver = new NinjectSignalRDependencyResolver(kernel);

            kernel.Bind <IStockTicker>().To <StockTicker>().InSingletonScope();
            kernel.Bind <IHubConnectionContext>()
            .ToMethod(context => resolver.Resolve <IConnectionManager>().GetHubContext <StockTickerHub>().Clients)
            .WhenInjectedInto <IStockTicker>();

            var config = new HubConfiguration()
            {
                Resolver = resolver
            };

            var heartBeat = GlobalHost.DependencyResolver.Resolve <ITransportHeartbeat>();
            var monitor   = new PresenceMonitor(heartBeat);

            monitor.StartMonitoring();

            //Using the ninject dependency resolver, the ITransportHeartbeat.GetConnections() in the PresenceMonitor never returns any connections
            app.MapSignalR(config);
        }
Ejemplo n.º 16
0
        public void Configuration(IAppBuilder app)
        {
            var kernel = new StandardKernel();
              var resolver = new NinjectSignalRDependencyResolver(kernel);

              kernel.Bind<IChat>()
            .To<SignalRChat.Chat>()  // Bind to Chat.
            .InSingletonScope();  // Make it a singleton object.

              kernel.Bind(typeof(IHubConnectionContext<dynamic>)).ToMethod(context =>
              resolver.Resolve<IConnectionManager>().GetHubContext<ChatHub>().Clients
               ).WhenInjectedInto<IChat>();

              kernel.Bind<IDbHandler>()
            .To<SignalRChat.DbHandler>()  // Bind to DbHandler.
            .InSingletonScope();  // Make it a singleton object.

              var config = new HubConfiguration();
              config.Resolver = resolver;

              SignalRChat.Startup.ConfigureSignalR(app, config);

              //app.MapSignalR();
        }
Ejemplo n.º 17
0
        private static void SetupSignalR(IKernel kernel, IAppBuilder app)
        {
            var resolver = new NinjectSignalRDependencyResolver(kernel);
            var connectionManager = resolver.Resolve<IConnectionManager>();
            var heartbeat = resolver.Resolve<ITransportHeartbeat>();
            var hubPipeline = resolver.Resolve<IHubPipeline>();

            kernel.Bind<IConnectionManager>()
                  .ToConstant(connectionManager);

            var config = new HubConfiguration
            {
                Resolver = resolver
            };

            hubPipeline.AddModule(kernel.Get<LoggingHubPipelineModule>());

            app.MapSignalR(config);

            var monitor = new PresenceMonitor(kernel, connectionManager, heartbeat);
            monitor.Start();
        }
Ejemplo n.º 18
0
        private static void SetupSignalR(IJabbrConfiguration jabbrConfig, IKernel kernel, IAppBuilder app)
        {
            var resolver = new NinjectSignalRDependencyResolver(kernel);
            var connectionManager = resolver.Resolve<IConnectionManager>();
            var heartbeat = resolver.Resolve<ITransportHeartbeat>();
            var hubPipeline = resolver.Resolve<IHubPipeline>();
            var configuration = resolver.Resolve<IConfigurationManager>();

            // Enable service bus scale out
            if (!String.IsNullOrEmpty(jabbrConfig.ServiceBusConnectionString) &&
                !String.IsNullOrEmpty(jabbrConfig.ServiceBusTopicPrefix))
            {
                var sbConfig = new ServiceBusScaleoutConfiguration(jabbrConfig.ServiceBusConnectionString,
                                                                   jabbrConfig.ServiceBusTopicPrefix)
                {
                    TopicCount = 5
                };

                resolver.UseServiceBus(sbConfig);
            }

            if (jabbrConfig.ScaleOutSqlServer)
            {
                resolver.UseSqlServer(ConfigurationManager.ConnectionStrings["Jabbr"].ConnectionString);
            }

            kernel.Bind<IConnectionManager>()
                  .ToConstant(connectionManager);

            // We need to extend this since the inital connect might take a while
            configuration.TransportConnectTimeout = TimeSpan.FromSeconds(30);

            var config = new HubConfiguration
            {
                Resolver = resolver
            };

            hubPipeline.AddModule(kernel.Get<LoggingHubPipelineModule>());

            app.MapSignalR(config);

            var monitor = new PresenceMonitor(kernel, connectionManager, heartbeat);
            monitor.Start();
        }
Ejemplo n.º 19
0
        private void SetupSignalR(IAppBuilder app, IKernel kernel)
        {
            var config = new HubConfiguration();
            var resolver = new NinjectSignalRDependencyResolver(kernel);
            var connectionManager = resolver.Resolve<IConnectionManager>();

            kernel.Bind<IConnectionManager>()
                  .ToConstant(connectionManager);
            config.Resolver = resolver;

            app.MapSignalR(config);
        }
Ejemplo n.º 20
0
        private static void SetupSignalR(IKernel kernel, IAppBuilder app)
        {
            var resolver = new NinjectSignalRDependencyResolver(kernel);
            var connectionManager = resolver.Resolve<IConnectionManager>();
            var heartbeat = resolver.Resolve<ITransportHeartbeat>();
            var hubPipeline = resolver.Resolve<IHubPipeline>();

            // Ah well loading system web.
            kernel.Bind<IProtectedData>()
                  .To<MachineKeyProtectedData>();

            kernel.Bind<IConnectionManager>()
                  .ToConstant(connectionManager);

            var config = new HubConfiguration
            {
                Resolver = resolver,
                EnableDetailedErrors = true
            };

            hubPipeline.AddModule(kernel.Get<LoggingHubPipelineModule>());

            app.MapHubs(config);

            var monitor = new PresenceMonitor(kernel, connectionManager, heartbeat);
            monitor.Start();
        }