public void AddConnectionHandler(PathString route, IWSConnectionHandler handler) { if (route == null) { throw new ArgumentNullException("route should not be null"); } if (handler == null) { throw new ArgumentNullException("handler should not be null"); } if (_mappings.ContainsKey(route)) { throw new ArgumentException("route: \"" + route + "\" already added in builder"); } _mappings.Add(route, handler); }
/// <summary> /// Middleware Configuration. /// The HTTP request pipeline that handles each request received. /// </summary> /// <param name="app"></param> /// <param name="env"></param> /// <param name="loggerFactory"></param> public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IServiceProvider serviceProvider) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); ILogger logger = loggerFactory.CreateLogger <Startup>(); AuthStartup.Configure(app); app.UseApplicationInsightsRequestTelemetry(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseBrowserLink(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseApplicationInsightsExceptionTelemetry(); app.UseStaticFiles(); app.UseSwagger(); app.UseSwaggerUi("api/ui", "/swagger/v" + MajorVersion + "/swagger.json"); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); app.UseWS((builder) => { IWSConnectionHandler mainHandler = serviceProvider.GetService <WSConnectionHandler>(); mainHandler.AddController(serviceProvider.GetService <SocketController>()); builder.AddConnectionHandler("/ws", mainHandler); }); }