File tree 1 file changed +15
-3
lines changed
src/net45/Extensions/WampSharp.RawSocket/RawSocket
1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -91,6 +91,16 @@ public async void Connect()
91
91
}
92
92
93
93
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 ( )
94
104
{
95
105
try
96
106
{
@@ -115,19 +125,21 @@ private async Task InnerConnect()
115
125
if ( handshakeResponse . IsError )
116
126
{
117
127
OnConnectionError (
118
- new WampConnectionErrorEventArgs ( new RawSocketProtocolException ( handshakeResponse . HandshakeError . Value ) ) ) ;
128
+ new WampConnectionErrorEventArgs ( new RawSocketProtocolException ( handshakeResponse
129
+ . HandshakeError . Value ) ) ) ;
119
130
}
120
131
else
121
132
{
122
133
Connection =
123
134
CreateInnerConnection ( stream , handshakeRequest , handshakeResponse ) ;
124
-
125
- await Task . Run ( Connection . HandleTcpClientAsync ) . ConfigureAwait ( false ) ;
126
135
}
136
+
137
+ return true ;
127
138
}
128
139
catch ( Exception ex )
129
140
{
130
141
OnConnectionError ( new WampConnectionErrorEventArgs ( ex ) ) ;
142
+ return false ;
131
143
}
132
144
}
133
145
You can’t perform that action at this time.
0 commit comments