File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed
src/net45/Extensions/WampSharp.RawSocket/RawSocket Expand file tree Collapse file tree 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()
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
You can’t perform that action at this time.
0 commit comments