本文整理汇总了C#中Microsoft.AspNet.SignalR.HubConfiguration类的典型用法代码示例。如果您正苦于以下问题:C# HubConfiguration类的具体用法?C# HubConfiguration怎么用?C# HubConfiguration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HubConfiguration类属于Microsoft.AspNet.SignalR命名空间,在下文中一共展示了HubConfiguration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Configuration
public void Configuration(IAppBuilder app)
{
var formatters = GlobalConfiguration.Configuration.Formatters;
var jsonFormatter = formatters.JsonFormatter;
var settings = jsonFormatter.SerializerSettings;
settings.Formatting = Formatting.Indented;
settings.ContractResolver = new CamelCasePropertyNamesContractResolver();
app.UseCors(CorsOptions.AllowAll);
ConfigureAuth(app);
// app.MapSignalR();
app.Map("/signalr", map =>
{
// Setup the CORS middleware to run before SignalR.
// By default this will allow all origins. You can
// configure the set of origins and/or http verbs by
// providing a cors options with a different policy.
map.UseCors(CorsOptions.AllowAll);
var hubConfiguration = new HubConfiguration
{
// You can enable JSONP by uncommenting line below.
// JSONP requests are insecure but some older browsers (and some
// versions of IE) require JSONP to work cross domain
// EnableJSONP = true
EnableDetailedErrors = true
};
// Run the SignalR pipeline. We're not using MapSignalR
// since this branch already runs under the "/signalr"
// path.
map.RunSignalR(hubConfiguration);
});
}
示例2: Configuration
public void Configuration(IAppBuilder app)
{
#region Global Configuration
GlobalHost.Configuration.ConnectionTimeout = TimeSpan.FromSeconds(110);
GlobalHost.Configuration.DisconnectTimeout = TimeSpan.FromSeconds(30);
GlobalHost.Configuration.KeepAlive = TimeSpan.FromSeconds(10);
GlobalHost.Configuration.DefaultMessageBufferSize = 500;
#endregion
#region Hub Configuration
var hubConfiguration = new HubConfiguration();
hubConfiguration.EnableDetailedErrors = true;
hubConfiguration.EnableJavaScriptProxies = true;
hubConfiguration.EnableJSONP = true;
#endregion
//var options = new CookieAuthenticationOptions()
//{
// CookieName = "Token"
//};
//app.UseCookieAuthentication(options);
//app.Use<LoginMiddleware>();
app.MapSignalR("/signalr", hubConfiguration);
}
示例3: Configuration
public void Configuration(IAppBuilder app)
{
//log4net.Config.XmlConfigurator.Configure();
var bootstrapper = new Bootstrapper();
var container = bootstrapper.Build();
var priceFeed = container.Resolve<IPriceFeed>();
priceFeed.Start();
var cleaner = container.Resolve<Cleaner>();
cleaner.Start();
app.UseCors(CorsOptions.AllowAll);
app.Map("/signalr", map =>
{
var hubConfiguration = new HubConfiguration
{
// you don't want to use that in prod, just when debugging
EnableDetailedErrors = true,
EnableJSONP = true,
Resolver = new AutofacSignalRDependencyResolver(container)
};
map.UseCors(CorsOptions.AllowAll)
.RunSignalR(hubConfiguration);
});
}
示例4: Configuration
public void Configuration(IAppBuilder app)
{
// Turn cross domain on
var config = new HubConfiguration { EnableCrossDomain = true };
// This will map out to http://localhost:8080/signalr by default
app.MapHubs(config);
}
示例5: Configuration
public void Configuration(IAppBuilder app)
{
app.UseErrorPage();
app.Map("/raw-connection", map =>
{
// Turns cors support on allowing everything
// In real applications, the origins should be locked down
map.UseCors(CorsOptions.AllowAll)
.RunSignalR<RawConnection>();
});
app.Map("/signalr", map =>
{
var config = new HubConfiguration
{
// You can enable JSONP by uncommenting this line
// JSONP requests are insecure but some older browsers (and some
// versions of IE) require JSONP to work cross domain
// EnableJSONP = true
};
// Turns cors support on allowing everything
// In real applications, the origins should be locked down
map.UseCors(CorsOptions.AllowAll)
.RunSignalR(config);
});
// Turn tracing on programmatically
GlobalHost.TraceManager.Switch.Level = SourceLevels.All;
}
示例6: Configuration
public void Configuration(IAppBuilder app)
{
//worsks to client
//app.UseCors(CorsOptions.AllowAll);
//app.MapSignalR();
//not working
// Branch the pipeline here for requests that start with "/signalr"
app.Map("/signalr", map =>
{
// Setup the CORS middleware to run before SignalR.
// By default this will allow all origins. You can
// configure the set of origins and/or http verbs by
// providing a cors options with a different policy.
map.UseCors(CorsOptions.AllowAll);
var hubConfiguration = new HubConfiguration
{
Resolver = new AutofacSignalRDependencyResolver(App.Container),
};
// Run the SignalR pipeline. We're not using MapSignalR
// since this branch already runs under the "/signalr"
// path.
map.RunSignalR(hubConfiguration);
});
}
示例7: Configure
public static IWindsorContainer Configure(
this IWindsorContainer container,
HubConfiguration configuration,
IAppBuilder app)
{
configuration.Resolver = new SignalRDependencyResolver(container);
container.Register(
Component
.For<IHubConnectionContext<dynamic>>()
.UsingFactoryMethod(k =>
configuration.Resolver.Resolve<IConnectionManager>()
.GetHubContext<ClientsHub>().Clients)
);
container.Register(
Classes
.FromAssemblyContaining<Startup>()
.BasedOn<IHub>()
.WithServiceSelf()
.LifestyleSingleton()
);
app.MapSignalR(configuration);
return container;
}
示例8: Configuration
public void Configuration(IAppBuilder app)
{
//Configure AutoMapper (http://automapper.codeplex.com/)
Mapper.Initialize(ConfigureMapper);
//Configure Bearer Authentication
OAuthOptions = new OAuthAuthorizationServerOptions();
app.UseOAuthBearerTokens(OAuthOptions);
//Configure AutoFac for DependencyResolver (http://autofac.org/)
IContainer container = RegisterServices();
var resolverForSignalr = new Autofac.Integration.SignalR.AutofacDependencyResolver(container);
var resolver = new App.Common.AutoFacDependencyResolver(container);
//Configure WebApi
var config = new HttpConfiguration() { DependencyResolver = resolver };
ConfigureWebApi(config);
app.UseWebApi(config);
//Configure SignalR self host
var hubConfiguration = new HubConfiguration() { Resolver = resolverForSignalr };
app.MapSignalR(hubConfiguration);
//Log trafic using Log4Net
app.Use(typeof(Logging));
// container.Resolve<IRavenRepository>();
//Set global dependency resolver for signalr
GlobalHost.DependencyResolver = resolverForSignalr;
}
示例9: Configuration
public void Configuration(IAppBuilder app)
{
var container = ObjectFactory.Container;
var resolver = new StructureMapSignalRDependencyResolver(container);
ObjectFactory.Configure(x =>
{
x.For<Microsoft.AspNet.SignalR.StockTicker.IStockTicker>()
.Singleton()
.Use<Microsoft.AspNet.SignalR.StockTicker.StockTicker>();
x.For<IHubConnectionContext>().ConditionallyUse(c =>
c.If(t => t.ParentType.GetInterface(typeof(Microsoft.AspNet.SignalR.StockTicker.IStockTicker).Name) ==
typeof(Microsoft.AspNet.SignalR.StockTicker.IStockTicker))
.ThenIt.Is.ConstructedBy(
() => resolver.Resolve<IConnectionManager>().GetHubContext<StockTickerHub>().Clients)
);
});
var config = new HubConfiguration()
{
Resolver = resolver
};
//Set GlobalHost dependency resolver to ensure hubs utilize the same configuration (http://jerodkrone.com/signalr-2-0-dependency-injection-using-globalhost/).
GlobalHost.DependencyResolver = resolver;
//Required For iPad, without this the "Spinner" will spin infinitely (https://github.com/SignalR/SignalR/issues/1406).
GlobalHost.Configuration.ConnectionTimeout = TimeSpan.FromSeconds(1);
GlobalHost.Configuration.LongPollDelay = TimeSpan.FromSeconds(5);
Microsoft.AspNet.SignalR.StockTicker.Startup.ConfigureSignalR(app, config);
}
示例10: Configuration
public void Configuration(IAppBuilder app)
{
// 有关如何配置应用程序的详细信息,请访问 http://go.microsoft.com/fwlink/?LinkID=316888
app.Map("/signalr", map =>
{
// Setup the cors middleware to run before SignalR.
// By default this will allow all origins. You can
// configure the set of origins and/or http verbs by
// providing a cors options with a different policy.
map.UseCors(CorsOptions.AllowAll);
var hubConfiguration = new HubConfiguration
{
// You can enable JSONP by uncommenting line below.
// JSONP requests are insecure but some older browsers (and some
// versions of IE) require JSONP to work cross domain
EnableJSONP = true
};
// Run the SignalR pipeline. We're not using MapSignalR
// since this branch is already runs under the "/signalr"
// path.
map.RunSignalR(hubConfiguration);
});
}
示例11: Configuration
public void Configuration(IAppBuilder app)
{
var httpConfig = new WebApiHttpConfiguration();
app.UseWebApi(httpConfig);
// Branch the pipeline here for requests that start with "/signalr"
app.Map("/signalr", map =>
{
// Setup the CORS middleware to run before SignalR. By default this will allow all origins.
// You can configure the set of origins and/or http verbs by providing a cors options with a different policy.
map.UseCors(CorsOptions.AllowAll);
var hubConfiguration = new HubConfiguration();
// handle custom serilaization for lowerCamelCase
var settings = new JsonSerializerSettings { ContractResolver = new SignalRContractResolver() };
var serializer = JsonSerializer.Create(settings);
GlobalHost.DependencyResolver.Register(typeof(JsonSerializer), () => serializer);
// Run the SignalR pipeline. We're not using MapSignalR since this branch already runs under the "/signalr" path.
map.RunSignalR(hubConfiguration);
});
// for static files: Install-Package Microsoft.Owin.StaticFiles
//var fileServerOptions = new FileServerOptions {};
//app.UseFileServer(fileServerOptions);
}
示例12: Configuration
public void Configuration(IAppBuilder app)
{
// For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=316888
// Branch the pipeline here for requests that start with "/signalr"
app.Map("/signalr", map =>
{
// Setup the CORS middleware to run before SignalR.
// By default this will allow all origins. You can
// configure the set of origins and/or http verbs by
// providing a cors options with a different policy.
map.UseCors(CorsOptions.AllowAll);
var hubConfiguration = new HubConfiguration
{
// You can enable JSONP by uncommenting line below.
// JSONP requests are insecure but some older browsers (and some
// versions of IE) require JSONP to work cross domain
// EnableJSONP = true
};
// Run the SignalR pipeline. We're not using MapSignalR
// since this branch already runs under the "/signalr"
// path.
map.RunSignalR(hubConfiguration);
});
HttpConfiguration httpConfig = new HttpConfiguration();
ConfigureOAuthTokenGeneration(app);
ConfigureWebApi(httpConfig);
app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);
app.UseWebApi(httpConfig);
}
示例13: Configuration
public void Configuration(IAppBuilder app)
{
var configuration = new HubConfiguration();
configuration.EnableDetailedErrors = true;
configuration.Resolver = new SignalRDependencyResolver();
app.MapSignalR(configuration);
}
示例14: Configure
public void Configure(IApplicationBuilder app)
{
app.UseStaticFiles();
app.UseStatusCodePages();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller}/{action}/{id?}",
defaults: new {controller = "Home", action = "Index"});
});
app.UseOwin(addToPipeline =>
{
addToPipeline(next =>
{
var builder = new AppBuilder();
var hubConfig = new HubConfiguration { EnableDetailedErrors = true };
builder.MapSignalR(hubConfig);
var appFunc = builder.Build(typeof(Func<IDictionary<string, object>, Task>)) as Func<IDictionary<string, object>, Task>;
return appFunc;
});
});
}
示例15: Configuration
public void Configuration(IAppBuilder app)
{
// For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=316888
HubConfiguration config = new HubConfiguration { EnableDetailedErrors = true, Resolver = new DefaultDependencyResolver() };
app.UseCors(CorsOptions.AllowAll);
app.MapSignalR(config);
}