From 76d3043bbea559647681376efa67334d05879dcb Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Fri, 24 Oct 2014 15:14:07 -0700 Subject: [PATCH] Update Autobahn server app with native and managed paths. --- test/AutobahnTestServer/Project.json | 8 ++++-- test/AutobahnTestServer/Startup.cs | 40 ++++++++++++++++++++-------- 2 files changed, 35 insertions(+), 13 deletions(-) diff --git a/test/AutobahnTestServer/Project.json b/test/AutobahnTestServer/Project.json index b1ac9e5da6..50dfc16dc4 100644 --- a/test/AutobahnTestServer/Project.json +++ b/test/AutobahnTestServer/Project.json @@ -4,9 +4,13 @@ "dependencies": { "Microsoft.AspNet.Server.IIS": "1.0.0-beta1-*", "Microsoft.AspNet.Server.WebListener": "1.0.0-beta1-*", - "Microsoft.AspNet.WebSockets.Server": "1.0.0-beta1-*" + "Microsoft.AspNet.WebSockets.Server": "1.0.0-beta1-*", + "Kestrel": "1.0.0-beta1-*" + }, + "commands": { + "web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:12345", + "kestrel": "Microsoft.AspNet.Hosting --server Kestrel --server.urls http://localhost:12344" }, - "commands": { "web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:12345" }, "frameworks" : { "aspnet50" : { }, "aspnetcore50" : { } diff --git a/test/AutobahnTestServer/Startup.cs b/test/AutobahnTestServer/Startup.cs index 1e17919b11..3a5692aadf 100644 --- a/test/AutobahnTestServer/Startup.cs +++ b/test/AutobahnTestServer/Startup.cs @@ -15,22 +15,40 @@ namespace AutobahnTestServer { public void Configure(IApplicationBuilder app) { - // Comment this out to test native server implementations - app.UseWebSockets(new WebSocketOptions() + app.Map("/Managed", managedWebSocketsApp => { - ReplaceFeature = true, + // Comment this out to test native server implementations + managedWebSocketsApp.UseWebSockets(new WebSocketOptions() + { + ReplaceFeature = true, + }); + + managedWebSocketsApp.Use(async (context, next) => + { + if (context.IsWebSocketRequest) + { + Console.WriteLine("Echo: " + context.Request.Path); + var webSocket = await context.AcceptWebSocketAsync(); + await Echo(webSocket); + return; + } + await next(); + }); }); - app.Use(async (context, next) => + app.Map("/Native", nativeWebSocketsApp => { - if (context.IsWebSocketRequest) + nativeWebSocketsApp.Use(async (context, next) => { - Console.WriteLine("Echo: " + context.Request.Path); - var webSocket = await context.AcceptWebSocketAsync(); - await Echo(webSocket); - return; - } - await next(); + if (context.IsWebSocketRequest) + { + Console.WriteLine("Echo: " + context.Request.Path); + var webSocket = await context.AcceptWebSocketAsync(); + await Echo(webSocket); + return; + } + await next(); + }); }); app.Run(context =>