File tree Expand file tree Collapse file tree
src/Microsoft.AspNet.WebSockets.Server Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11// Copyright (c) .NET Foundation. All rights reserved.
22// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33
4+ using System ;
45using Microsoft . AspNet . WebSockets . Server ;
56
67namespace Microsoft . AspNet . Builder
@@ -9,11 +10,28 @@ public static class WebSocketMiddlewareExtensions
910 {
1011 public static IApplicationBuilder UseWebSockets ( this IApplicationBuilder builder )
1112 {
12- return builder . UseWebSockets ( new WebSocketOptions ( ) ) ;
13+ if ( builder == null )
14+ {
15+ throw new ArgumentNullException ( nameof ( builder ) ) ;
16+ }
17+
18+ return builder . UseWebSockets ( options => { } ) ;
1319 }
1420
15- public static IApplicationBuilder UseWebSockets ( this IApplicationBuilder builder , WebSocketOptions options ) // TODO: [NotNull]
21+ public static IApplicationBuilder UseWebSockets ( this IApplicationBuilder builder , Action < WebSocketOptions > configureOptions )
1622 {
23+ if ( builder == null )
24+ {
25+ throw new ArgumentNullException ( nameof ( builder ) ) ;
26+ }
27+ if ( configureOptions == null )
28+ {
29+ throw new ArgumentNullException ( nameof ( configureOptions ) ) ;
30+ }
31+
32+ var options = new WebSocketOptions ( ) ;
33+ configureOptions ( options ) ;
34+
1735 return builder . Use ( next => new WebSocketMiddleware ( next , options ) . Invoke ) ;
1836 }
1937 }
Original file line number Diff line number Diff line change 88using Microsoft . AspNet . Builder ;
99using Microsoft . AspNet . Hosting ;
1010using Microsoft . AspNet . Http ;
11- using Microsoft . AspNet . WebSockets . Server ;
1211
1312namespace AutobahnTestServer
1413{
@@ -19,9 +18,9 @@ public void Configure(IApplicationBuilder app)
1918 app . Map ( "/Managed" , managedWebSocketsApp =>
2019 {
2120 // Comment this out to test native server implementations
22- managedWebSocketsApp . UseWebSockets ( new WebSocketOptions ( )
21+ managedWebSocketsApp . UseWebSockets ( options =>
2322 {
24- ReplaceFeature = true ,
23+ options . ReplaceFeature = true ;
2524 } ) ;
2625
2726 managedWebSocketsApp . Use ( async ( context , next ) =>
You can’t perform that action at this time.
0 commit comments