Update Autobahn server app with native and managed paths.

This commit is contained in:
Chris Ross 2014-10-24 15:14:07 -07:00
parent 98e9285fa8
commit 76d3043bbe
2 changed files with 35 additions and 13 deletions

View File

@ -4,9 +4,13 @@
"dependencies": { "dependencies": {
"Microsoft.AspNet.Server.IIS": "1.0.0-beta1-*", "Microsoft.AspNet.Server.IIS": "1.0.0-beta1-*",
"Microsoft.AspNet.Server.WebListener": "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" : { "frameworks" : {
"aspnet50" : { }, "aspnet50" : { },
"aspnetcore50" : { } "aspnetcore50" : { }

View File

@ -14,14 +14,16 @@ namespace AutobahnTestServer
public class Startup public class Startup
{ {
public void Configure(IApplicationBuilder app) public void Configure(IApplicationBuilder app)
{
app.Map("/Managed", managedWebSocketsApp =>
{ {
// Comment this out to test native server implementations // Comment this out to test native server implementations
app.UseWebSockets(new WebSocketOptions() managedWebSocketsApp.UseWebSockets(new WebSocketOptions()
{ {
ReplaceFeature = true, ReplaceFeature = true,
}); });
app.Use(async (context, next) => managedWebSocketsApp.Use(async (context, next) =>
{ {
if (context.IsWebSocketRequest) if (context.IsWebSocketRequest)
{ {
@ -32,6 +34,22 @@ namespace AutobahnTestServer
} }
await next(); await next();
}); });
});
app.Map("/Native", nativeWebSocketsApp =>
{
nativeWebSocketsApp.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.Run(context => app.Run(context =>
{ {