示例#1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            app.UseLiteWebSocket(new LiteWebSocketOptions()
            {
                BasePath = new PathString("/test/lws")
            });

            MessageControllerResolver resolver = app.ApplicationServices.GetService <MessageControllerResolver>();

            resolver.AddSupportedMessage <TestMessageScope.Test1>();
            resolver.AddSupportedMessage <TestMessageScope.Test2>();
            resolver.AddSupportedMessage <TestMessageScope.Test3>();
            resolver.RegisterController <TestController>();

            LiteWebSocketDefaults.Filters.Add(new GlobalFilter());

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseBrowserLink();
            }
            else
            {
                app.UseExceptionHandler("/Error");
            }

            app.UseStaticFiles();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller}/{action=Index}/{id?}");
            });
        }
 public static Action <IApplicationBuilder> SocketWsHandler(MessageControllerResolver resolver)
 {
     return((Action <IApplicationBuilder>)(app =>
     {
         app.Run(FunctionWrappersExtensions.AsWsEndpoint(async(context, webSocket) =>
         {
             await webSocket.CloseAsync(WebSocketCloseStatus.NormalClosure, "result.CloseStatusDescription", CancellationToken.None);
         }));
     }));
 }
 public static Action <IApplicationBuilder> SyncHandler(MessageControllerResolver resolver)
 {
     return((Action <IApplicationBuilder>)(app =>
     {
         app.Run(FunctionWrappersExtensions.AsHttpEndpoint(async context =>
         {
             await context.Response.WriteBodyAsStringAsync(resolver.AcceptSerializedBulk(await context.Request.ReadBodyAsStringAsync()), "application/json");
         }));
     }));
 }
 public static Action <IApplicationBuilder> SocketHandler(MessageControllerResolver resolver)
 {
     return((Action <IApplicationBuilder>)(app =>
     {
         app.Run(FunctionWrappersExtensions.AsHttpEndpoint(async context =>
         {
             //resolver.Accept()
             await context.Response.WriteAsync("Socket");
         }));
     }));
 }