88use React \Dns \Resolver \Resolver ;
99use React \Stream \Stream ;
1010use React \EventLoop \LoopInterface ;
11- use ConnectionManager \ConnectionManagerInterface ;
12- use ConnectionManager \SecureConnectionManager ;
11+ use React \SocketClient \ConnectorInterface ;
12+ use React \SocketClient \SecureConnector ;
13+ use Socks \Connector ;
1314use \Exception ;
1415use \InvalidArgumentException ;
1516use \UnexpectedValueException ;
1617
17- class Client implements ConnectionManagerInterface
18+ class Client
1819{
1920 /**
2021 *
21- * @var ConnectionManagerInterface
22+ * @var ConnectorInterface
2223 */
23- private $ connectionManager ;
24+ private $ connector ;
2425
2526 /**
2627 *
@@ -45,10 +46,10 @@ class Client implements ConnectionManagerInterface
4546
4647 protected $ auth = null ;
4748
48- public function __construct (LoopInterface $ loop , ConnectionManagerInterface $ connectionManager , Resolver $ resolver , $ socksHost , $ socksPort )
49+ public function __construct (LoopInterface $ loop , ConnectorInterface $ connector , Resolver $ resolver , $ socksHost , $ socksPort )
4950 {
5051 $ this ->loop = $ loop ;
51- $ this ->connectionManager = $ connectionManager ;
52+ $ this ->connector = $ connector ;
5253 $ this ->socksHost = $ socksHost ;
5354 $ this ->socksPort = $ socksPort ;
5455 $ this ->resolver = $ resolver ;
@@ -110,12 +111,17 @@ public function unsetAuth()
110111
111112 public function createHttpClient ()
112113 {
113- return new HttpClient ($ this ->loop , $ this , $ this ->createSecureConnectionManager ());
114+ return new HttpClient ($ this ->loop , $ this -> createConnector () , $ this ->createSecureConnector ());
114115 }
115116
116- public function createSecureConnectionManager ()
117+ public function createSecureConnector ()
117118 {
118- return new SecureConnectionManager ($ this , $ this ->loop );
119+ return new SecureConnector ($ this ->createConnector (), $ this ->loop );
120+ }
121+
122+ public function createConnector ()
123+ {
124+ return new Connector ($ this );
119125 }
120126
121127 public function getConnection ($ host , $ port )
@@ -145,7 +151,7 @@ public function getConnection($host, $port)
145151 $ that = $ this ;
146152 When::all (
147153 array (
148- $ this ->connectionManager -> getConnection ($ this ->socksHost , $ this ->socksPort )->then (
154+ $ this ->connector -> create ($ this ->socksHost , $ this ->socksPort )->then (
149155 null ,
150156 function ($ error ) {
151157 throw new Exception ('Unable to connect to socks server ' , 0 , $ error );
0 commit comments