示例#1
0
        public void Configuration(IAppBuilder app)
        {
            //Configure the hub with dependency injection. (Use IOC container, not like this..)
            GlobalHost.DependencyResolver.Register(
                typeof(DemoHub),
                () => new DemoHub(new DemoHubProxy(new ResonanceHubMemoryRepository <DemoServiceInformation>())));

            GlobalHost.DependencyResolver.Register(typeof(LoggingHub), () => new LoggingHub());

            app.UseCors(CorsOptions.AllowAll);
            app.MapSignalR(new HubConfiguration()
            {
                EnableDetailedErrors = true //Include exception messages from hub!
            });

            GlobalHost.Configuration.MaxIncomingWebSocketMessageSize = null;       //Unlimited message size.
            GlobalHost.Configuration.DisconnectTimeout = TimeSpan.FromSeconds(10); //Optional, configure the reconnection timeout (minimum 6 seconds).

            LoggingConfiguration.ConfigureLogging();

            LoggingConfiguration.LogReceived += (x, e) =>
            {
                LoggingHub.PublishLog(e);
            };
        }
示例#2
0
        // This code configures Web API. The Startup class is specified as a type
        // parameter in the WebApp.Start method.
        public void Configuration(IAppBuilder appBuilder)
        {
            // Configure Web API for self-host.
            HttpConfiguration config = new HttpConfiguration();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );

            appBuilder.UseWebApi(config);

            var fileSystem = new PhysicalFileSystem(".");
            var options    = new FileServerOptions
            {
                EnableDefaultFiles = true,
                FileSystem         = fileSystem
            };

            appBuilder.UseFileServer(options);

            //Configure the hub with dependency injection. (Use IOC container, not like this..)
            GlobalHost.DependencyResolver.Register(
                typeof(DemoHub),
                () => new DemoHub(new DemoHubProxy(new ResonanceHubMemoryRepository <DemoServiceInformation>())));

            GlobalHost.DependencyResolver.Register(typeof(LoggingHub), () => new LoggingHub());

            appBuilder.UseCors(CorsOptions.AllowAll);
            appBuilder.MapSignalR(new HubConfiguration()
            {
                EnableDetailedErrors = true //Include exception messages from hub!
            });

            GlobalHost.Configuration.MaxIncomingWebSocketMessageSize = null; //Unlimited message size.

            LoggingConfiguration.ConfigureLogging();

            LoggingConfiguration.LogReceived += (x, e) =>
            {
                LoggingHub.PublishLog(e);
            };
        }