Skip to content

Commit 62fcac0

Browse files
author
Elad Zelingher
committed
Changed AspNetCoreWebSocketTransport's Open method
1 parent f847081 commit 62fcac0

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

src/net45/Extensions/WampSharp.AspNetCore.WebSockets.Server/AspNetCoreWebSocketTransport.cs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,20 @@ namespace WampSharp.AspNetCore.WebSockets.Server
1515
{
1616
public class AspNetCoreWebSocketTransport : WebSocketTransport<WebSocketData>
1717
{
18-
private readonly IApplicationBuilder mApp;
18+
private Func<HttpContext, Func<Task>, Task> mHandler;
1919

2020
public AspNetCoreWebSocketTransport
2121
(IApplicationBuilder app,
2222
ICookieAuthenticatorFactory authenticatorFactory = null) :
2323
base(authenticatorFactory)
2424
{
25-
mApp = app;
25+
mHandler = this.EmptyHandler;
26+
app.Use(HttpHandler);
2627
}
2728

2829
public override void Dispose()
2930
{
30-
throw new NotImplementedException();
31+
mHandler = this.EmptyHandler;
3132
}
3233

3334
protected override void OpenConnection<TMessage>(WebSocketData original, IWampConnection<TMessage> connection)
@@ -68,10 +69,20 @@ protected override IWampConnection<TMessage> CreateTextConnection<TMessage>
6869

6970
public override void Open()
7071
{
71-
mApp.Use(HttpHandler);
72+
mHandler = this.WebSocketHandler;
7273
}
7374

74-
private async Task HttpHandler(HttpContext context, Func<Task> next)
75+
private Task HttpHandler(HttpContext context, Func<Task> next)
76+
{
77+
return mHandler(context, next);
78+
}
79+
80+
private async Task EmptyHandler(HttpContext context, Func<Task> next)
81+
{
82+
await next();
83+
}
84+
85+
private async Task WebSocketHandler(HttpContext context, Func<Task> next)
7586
{
7687
if (context.WebSockets.IsWebSocketRequest)
7788
{

src/net45/WampSharpDotNet.sln

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "WampSharp.RawSocket", "Exte
3232
EndProject
3333
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "WampSharp.Default.Client", "WampSharp.Default.Client\WampSharp.Default.Client.xproj", "{1485A2E0-E225-47D8-A26B-077C44094C07}"
3434
EndProject
35+
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "WampSharp.AspNetCore.WebSockets.Server", "Extensions\WampSharp.AspNetCore.WebSockets.Server\WampSharp.AspNetCore.WebSockets.Server.xproj", "{841605EB-80CE-48C7-8CAE-0366FECFAED1}"
36+
EndProject
3537
Global
3638
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3739
Debug|Any CPU = Debug|Any CPU
@@ -70,6 +72,10 @@ Global
7072
{1485A2E0-E225-47D8-A26B-077C44094C07}.Debug|Any CPU.Build.0 = Debug|Any CPU
7173
{1485A2E0-E225-47D8-A26B-077C44094C07}.Release|Any CPU.ActiveCfg = Release|Any CPU
7274
{1485A2E0-E225-47D8-A26B-077C44094C07}.Release|Any CPU.Build.0 = Release|Any CPU
75+
{841605EB-80CE-48C7-8CAE-0366FECFAED1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
76+
{841605EB-80CE-48C7-8CAE-0366FECFAED1}.Debug|Any CPU.Build.0 = Debug|Any CPU
77+
{841605EB-80CE-48C7-8CAE-0366FECFAED1}.Release|Any CPU.ActiveCfg = Release|Any CPU
78+
{841605EB-80CE-48C7-8CAE-0366FECFAED1}.Release|Any CPU.Build.0 = Release|Any CPU
7379
EndGlobalSection
7480
GlobalSection(SolutionProperties) = preSolution
7581
HideSolutionNode = FALSE
@@ -85,5 +91,6 @@ Global
8591
{500B79FA-CAD0-4692-85BD-9682124DA872} = {EF15CA4F-CCAA-4435-A0B3-0E7FC1B955CD}
8692
{F3EAF470-1D65-45F5-BD49-EE4BB1D42A3A} = {234FC630-9975-4DD9-8A28-DAA75BB1DD7E}
8793
{1485A2E0-E225-47D8-A26B-077C44094C07} = {A034FCD9-A025-4F24-9E26-3D438944A526}
94+
{841605EB-80CE-48C7-8CAE-0366FECFAED1} = {234FC630-9975-4DD9-8A28-DAA75BB1DD7E}
8895
EndGlobalSection
8996
EndGlobal

0 commit comments

Comments
 (0)