Skip to content

Commit 33da566

Browse files
committed
Correcting behavior
1 parent dadcd7c commit 33da566

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/net45/Extensions/WampSharp.RawSocket/RawSocket/RawSocketClientConnection.cs

+15-3
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,16 @@ public async void Connect()
9191
}
9292

9393
private async Task InnerConnect()
94+
{
95+
bool connected = await TryConnect().ConfigureAwait(false);
96+
97+
if (connected)
98+
{
99+
await Task.Run(Connection.HandleTcpClientAsync).ConfigureAwait(false);
100+
}
101+
}
102+
103+
private async Task<bool> TryConnect()
94104
{
95105
try
96106
{
@@ -115,19 +125,21 @@ private async Task InnerConnect()
115125
if (handshakeResponse.IsError)
116126
{
117127
OnConnectionError(
118-
new WampConnectionErrorEventArgs(new RawSocketProtocolException(handshakeResponse.HandshakeError.Value)));
128+
new WampConnectionErrorEventArgs(new RawSocketProtocolException(handshakeResponse
129+
.HandshakeError.Value)));
119130
}
120131
else
121132
{
122133
Connection =
123134
CreateInnerConnection(stream, handshakeRequest, handshakeResponse);
124-
125-
await Task.Run(Connection.HandleTcpClientAsync).ConfigureAwait(false);
126135
}
136+
137+
return true;
127138
}
128139
catch (Exception ex)
129140
{
130141
OnConnectionError(new WampConnectionErrorEventArgs(ex));
142+
return false;
131143
}
132144
}
133145

0 commit comments

Comments
 (0)