protected override MessageBus CreateMessageBus() { var config = new SqlScaleoutConfiguration(RunData.SqlConnectionString) { TableCount = RunData.SqlTableCount }; return(new SqlMessageBus(Resolver, config)); }
public void TableCountValidated(int tableCount, bool isValid) { var config = new SqlScaleoutConfiguration("dummy"); if (isValid) { config.TableCount = tableCount; } else { Assert.Throws(typeof(ArgumentOutOfRangeException), () => config.TableCount = tableCount); } }
public void Configuration(IAppBuilder app) { var connectionString = "PUT HERE YOUR CONNECTION STRING"; /* Example of connection string: * @"server=.\SQLExpress;database=signalrscaleout;Trusted_Connection=yes"; */ var config = new SqlScaleoutConfiguration(connectionString) { TableCount = 5 }; GlobalHost.DependencyResolver.UseSqlServer(config); app.MapSignalR(); }
internal SqlMessageBus(IDependencyResolver resolver, SqlScaleoutConfiguration configuration, IDbProviderFactory dbProviderFactory) : base(resolver, configuration) { if (configuration == null) { throw new ArgumentNullException("configuration"); } _connectionString = configuration.ConnectionString; _configuration = configuration; _dbProviderFactory = dbProviderFactory; var traceManager = resolver.Resolve<ITraceManager>(); _trace = traceManager["SignalR." + typeof(SqlMessageBus).Name]; ThreadPool.QueueUserWorkItem(Initialize); }
internal SqlMessageBus(IDependencyResolver resolver, SqlScaleoutConfiguration configuration, IDbProviderFactory dbProviderFactory) : base(resolver, configuration) { if (configuration == null) { throw new ArgumentNullException("configuration"); } _connectionString = configuration.ConnectionString; _configuration = configuration; _dbProviderFactory = dbProviderFactory; var traceManager = resolver.Resolve <ITraceManager>(); _trace = traceManager["SignalR." + typeof(SqlMessageBus).Name]; ThreadPool.QueueUserWorkItem(Initialize); }
/// <summary> /// Creates a new instance of the SqlMessageBus class. /// </summary> /// <param name="resolver">The resolver to use.</param> /// <param name="configuration">The SQL scale-out configuration options.</param> public SqlMessageBus(IDependencyResolver resolver, SqlScaleoutConfiguration configuration) : this(resolver, configuration, SqlClientFactory.Instance.AsIDbProviderFactory()) { }
// For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864 private static void ConfigureAuth(IAppBuilder app) { app.CreatePerOwinContext(ApplicationDbContext.Create); app.CreatePerOwinContext <ApplicationUserManager>(ApplicationUserManager.Create); // Enable the application to use a cookie to store information for the signed in user app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, Provider = new CookieAuthenticationProvider { // Enables the application to validate the security stamp when the user logs in. // This is a security feature which is used when you change a password or add an external login to your account. OnValidateIdentity = SecurityStampValidator.OnValidateIdentity <ApplicationUserManager, ApplicationUser>( validateInterval: TimeSpan.FromMinutes(2), regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager)), OnApplyRedirect = ctx => { if (!IsApiRequest(ctx.Request)) { ctx.Response.Redirect(ctx.RedirectUri); } } }, #if !DEBUG CookieSecure = CookieSecureOption.Always, #endif CookieName = "Cryptopia", LoginPath = new PathString("/Login"), ExpireTimeSpan = TimeSpan.FromHours(8), LogoutPath = new PathString("/LogOff"), }); // Use a cookie to temporarily store information about a user logging in with a third party login provider //app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie); app.UseTwoFactorSignInCookie(DefaultAuthenticationTypes.TwoFactorCookie, TimeSpan.FromMinutes(5)); // Signalr var hubConfiguration = new HubConfiguration { #if DEBUG EnableDetailedErrors = true, #else EnableDetailedErrors = false #endif }; var useRedisSignalr = bool.Parse(WebConfigurationManager.AppSettings["Signalr_ScaleOut_Redis_Enabled"]); if (useRedisSignalr) { var redisConnection = WebConfigurationManager.AppSettings["Signalr_ScaleOut_Redis_Connection"]; var redisConfig = new RedisScaleoutConfiguration(redisConnection, "Cryptopia.Signalr"); redisConfig.MaxQueueLength = int.MaxValue; redisConfig.QueueBehavior = QueuingBehavior.Always; GlobalHost.DependencyResolver.UseRedis(redisConfig); } var useSqlSignalr = bool.Parse(WebConfigurationManager.AppSettings["Signalr_ScaleOut_Sql_Enabled"]); if (useSqlSignalr) { var sqlConnection = WebConfigurationManager.ConnectionStrings["SignalrBackplane"].ConnectionString; var sqlConfig = new SqlScaleoutConfiguration(sqlConnection); sqlConfig.TableCount = int.Parse(WebConfigurationManager.AppSettings["Signalr_ScaleOut_Sql_TableCount"]); sqlConfig.MaxQueueLength = int.MaxValue; sqlConfig.QueueBehavior = QueuingBehavior.Always; GlobalHost.DependencyResolver.UseSqlServer(sqlConfig); } GlobalHost.DependencyResolver.Register(typeof(IUserIdProvider), () => new HubIdentityProvider()); GlobalHost.Configuration.DefaultMessageBufferSize = 200; app.MapSignalR(hubConfiguration); }
protected override MessageBus CreateMessageBus() { var config = new SqlScaleoutConfiguration(RunData.SqlConnectionString) { TableCount = RunData.SqlTableCount }; return new SqlMessageBus(Resolver, config); }