@@ -170,11 +170,12 @@ public override void Negotiate(string host, int port)
170
170
/// <param name="remoteEP">An IPEndPoint that represents the remote device.</param>
171
171
/// <param name="callback">The method to call when the negotiation is complete.</param>
172
172
/// <param name="proxyEndPoint">The IPEndPoint of the HTTPS proxy server.</param>
173
+ /// <param name="state">The state.</param>
173
174
/// <returns>An IAsyncProxyResult that references the asynchronous connection.</returns>
174
175
public override IAsyncProxyResult BeginNegotiate ( IPEndPoint remoteEP , HandShakeComplete callback ,
175
- IPEndPoint proxyEndPoint )
176
+ IPEndPoint proxyEndPoint , object state )
176
177
{
177
- return BeginNegotiate ( remoteEP . Address . ToString ( ) , remoteEP . Port , callback , proxyEndPoint ) ;
178
+ return BeginNegotiate ( remoteEP . Address . ToString ( ) , remoteEP . Port , callback , proxyEndPoint , state ) ;
178
179
}
179
180
180
181
/// <summary>
@@ -184,14 +185,15 @@ public override IAsyncProxyResult BeginNegotiate(IPEndPoint remoteEP, HandShakeC
184
185
/// <param name="port">The port to connect to.</param>
185
186
/// <param name="callback">The method to call when the negotiation is complete.</param>
186
187
/// <param name="proxyEndPoint">The IPEndPoint of the HTTPS proxy server.</param>
188
+ /// <param name="state">The state.</param>
187
189
/// <returns>An IAsyncProxyResult that references the asynchronous connection.</returns>
188
190
public override IAsyncProxyResult BeginNegotiate ( string host , int port , HandShakeComplete callback ,
189
- IPEndPoint proxyEndPoint )
191
+ IPEndPoint proxyEndPoint , object state )
190
192
{
191
193
ProtocolComplete = callback ;
192
194
Buffer = GetConnectBytes ( host , port ) ;
193
- Server . BeginConnect ( proxyEndPoint , new AsyncCallback ( this . OnConnect ) , Server ) ;
194
- AsyncResult = new IAsyncProxyResult ( ) ;
195
+ Server . BeginConnect ( proxyEndPoint , this . OnConnect , Server ) ;
196
+ AsyncResult = new IAsyncProxyResult ( state ) ;
195
197
return AsyncResult ;
196
198
}
197
199
@@ -213,7 +215,7 @@ private void OnConnect(IAsyncResult ar)
213
215
214
216
try
215
217
{
216
- Server . BeginSend ( Buffer , 0 , Buffer . Length , SocketFlags . None , new AsyncCallback ( this . OnConnectSent ) ,
218
+ Server . BeginSend ( Buffer , 0 , Buffer . Length , SocketFlags . None , this . OnConnectSent ,
217
219
null ) ;
218
220
}
219
221
catch ( Exception e )
@@ -233,7 +235,7 @@ private void OnConnectSent(IAsyncResult ar)
233
235
HandleEndSend ( ar , Buffer . Length ) ;
234
236
Buffer = new byte [ 13 ] ;
235
237
Received = 0 ;
236
- Server . BeginReceive ( Buffer , 0 , 13 , SocketFlags . None , new AsyncCallback ( this . OnConnectReceive ) , Server ) ;
238
+ Server . BeginReceive ( Buffer , 0 , 13 , SocketFlags . None , this . OnConnectReceive , Server ) ;
237
239
}
238
240
catch ( Exception e )
239
241
{
@@ -262,7 +264,7 @@ private void OnConnectReceive(IAsyncResult ar)
262
264
if ( Received < 13 )
263
265
{
264
266
Server . BeginReceive ( Buffer , Received , 13 - Received , SocketFlags . None ,
265
- new AsyncCallback ( this . OnConnectReceive ) , Server ) ;
267
+ this . OnConnectReceive , Server ) ;
266
268
}
267
269
else
268
270
{
@@ -305,7 +307,7 @@ private void ReadUntilHeadersEnd(bool readFirstByte)
305
307
}
306
308
else
307
309
{
308
- Server . BeginReceive ( Buffer , 0 , 1 , SocketFlags . None , new AsyncCallback ( this . OnEndHeadersReceive ) ,
310
+ Server . BeginReceive ( Buffer , 0 , 1 , SocketFlags . None , this . OnEndHeadersReceive ,
309
311
Server ) ;
310
312
}
311
313
}
0 commit comments