44using System . Threading . Tasks ;
55using Newtonsoft . Json ;
66using Newtonsoft . Json . Linq ;
7+ using SuperSocket . ClientEngine ;
78//using Nito.AsyncEx;
89using WebSocket4Net ;
910
@@ -16,6 +17,7 @@ internal class Connection
1617 private readonly string _url ;
1718 private readonly IPusher _pusher ;
1819 private bool _allowReconnect = true ;
20+ private Func < IProxyConnector > _proxyFactory ;
1921
2022 private int _backOffMillis ;
2123
@@ -31,10 +33,11 @@ internal class Connection
3133 private TaskCompletionSource < ConnectionState > _connectionTaskComplete = null ;
3234 private TaskCompletionSource < ConnectionState > _disconnectionTaskComplete = null ;
3335
34- public Connection ( IPusher pusher , string url )
36+ public Connection ( IPusher pusher , string url , Func < IProxyConnector > proxyFactory = null )
3537 {
3638 _pusher = pusher ;
3739 _url = url ;
40+ _proxyFactory = proxyFactory ;
3841 }
3942
4043 internal Task < ConnectionState > Connect ( )
@@ -57,7 +60,8 @@ internal Task<ConnectionState> Connect()
5760 _websocket = new WebSocket ( _url )
5861 {
5962 EnableAutoSendPing = true ,
60- AutoSendPingInterval = 1
63+ AutoSendPingInterval = 1 ,
64+ Proxy = _proxyFactory ? . Invoke ( ) ,
6165 } ;
6266
6367 _websocket . Opened += websocket_Opened ;
0 commit comments