Skip to content

Commit 59f1d20

Browse files
committed
Simplify usage by supporting new Socket API without nullable loop args
1 parent 255e891 commit 59f1d20

30 files changed

+147
-145
lines changed

README.md

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ $http = new React\Http\HttpServer(function (Psr\Http\Message\ServerRequestInterf
107107
);
108108
});
109109

110-
$socket = new React\Socket\Server(8080);
110+
$socket = new React\Socket\SocketServer('127.0.0.1:8080');
111111
$http->listen($socket);
112112
```
113113

@@ -261,7 +261,6 @@ like this:
261261
$browser = new React\Http\Browser(
262262
null,
263263
new React\Socket\Connector(
264-
null,
265264
array(
266265
'timeout' => 5
267266
)
@@ -605,7 +604,7 @@ $proxy = new Clue\React\HttpProxy\ProxyConnector(
605604
new React\Socket\Connector()
606605
);
607606

608-
$connector = new React\Socket\Connector(null, array(
607+
$connector = new React\Socket\Connector(array(
609608
'tcp' => $proxy,
610609
'dns' => false
611610
));
@@ -632,7 +631,7 @@ $proxy = new Clue\React\Socks\Client(
632631
new React\Socket\Connector()
633632
);
634633

635-
$connector = new React\Socket\Connector(null, array(
634+
$connector = new React\Socket\Connector(array(
636635
'tcp' => $proxy,
637636
'dns' => false
638637
));
@@ -661,7 +660,7 @@ plain HTTP and TLS-encrypted HTTPS.
661660
```php
662661
$proxy = new Clue\React\SshProxy\SshSocksConnector('me@localhost:22', Loop::get());
663662

664-
$connector = new React\Socket\Connector(null, array(
663+
$connector = new React\Socket\Connector(array(
665664
'tcp' => $proxy,
666665
'dns' => false
667666
));
@@ -742,13 +741,13 @@ to be attached to an instance of
742741
[`React\Socket\ServerInterface`](https://github.com/reactphp/socket#serverinterface)
743742
through the [`listen()`](#listen) method as described in the following
744743
chapter. In its most simple form, you can attach this to a
745-
[`React\Socket\Server`](https://github.com/reactphp/socket#server) in order
746-
to start a plaintext HTTP server like this:
744+
[`React\Socket\SocketServer`](https://github.com/reactphp/socket#socketserver)
745+
in order to start a plaintext HTTP server like this:
747746

748747
```php
749748
$http = new React\Http\HttpServer($handler);
750749

751-
$socket = new React\Socket\Server('0.0.0.0:8080');
750+
$socket = new React\Socket\SocketServer('0.0.0.0:8080');
752751
$http->listen($socket);
753752
```
754753

@@ -870,13 +869,13 @@ is responsible for emitting the underlying streaming connections. This
870869
HTTP server needs to be attached to it in order to process any
871870
connections and pase incoming streaming data as incoming HTTP request
872871
messages. In its most common form, you can attach this to a
873-
[`React\Socket\Server`](https://github.com/reactphp/socket#server) in
874-
order to start a plaintext HTTP server like this:
872+
[`React\Socket\SocketServer`](https://github.com/reactphp/socket#socketserver)
873+
in order to start a plaintext HTTP server like this:
875874

876875
```php
877876
$http = new React\Http\HttpServer($handler);
878877

879-
$socket = new React\Socket\Server('0.0.0.0:8080');
878+
$socket = new React\Socket\SocketServer('0.0.0.0:8080');
880879
$http->listen($socket);
881880
```
882881

@@ -895,16 +894,16 @@ Likewise, it's usually recommended to use a reverse proxy setup to accept
895894
secure HTTPS requests on default HTTPS port `443` (TLS termination) and
896895
only route plaintext requests to this HTTP server. As an alternative, you
897896
can also accept secure HTTPS requests with this HTTP server by attaching
898-
this to a [`React\Socket\Server`](https://github.com/reactphp/socket#server)
897+
this to a [`React\Socket\SocketServer`](https://github.com/reactphp/socket#socketserver)
899898
using a secure TLS listen address, a certificate file and optional
900899
`passphrase` like this:
901900

902901
```php
903902
$http = new React\Http\HttpServer($handler);
904903

905-
$socket = new React\Socket\Server('tls://0.0.0.0:8443', null, array(
904+
$socket = new React\Socket\SocketServer('tls://0.0.0.0:8443', array('tls' => array(
906905
'local_cert' => __DIR__ . '/localhost.pem'
907-
));
906+
)));
908907
$http->listen($socket);
909908
```
910909

@@ -1886,7 +1885,7 @@ proxy servers etc.), you can explicitly pass a custom instance of the
18861885
[`ConnectorInterface`](https://github.com/reactphp/socket#connectorinterface):
18871886

18881887
```php
1889-
$connector = new React\Socket\Connector(null, array(
1888+
$connector = new React\Socket\Connector(array(
18901889
'dns' => '127.0.0.1',
18911890
'tcp' => array(
18921891
'bindto' => '192.168.10.1:0'

composer.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"react/event-loop": "^1.2",
3333
"react/promise": "^2.3 || ^1.2.1",
3434
"react/promise-stream": "^1.1",
35-
"react/socket": "^1.8",
35+
"react/socket": "dev-connector-signature as 1.9.0",
3636
"react/stream": "^1.2",
3737
"ringcentral/psr7": "^1.2"
3838
},
@@ -48,5 +48,11 @@
4848
},
4949
"autoload-dev": {
5050
"psr-4": { "React\\Tests\\Http\\": "tests" }
51-
}
51+
},
52+
"repositories": [
53+
{
54+
"type": "vcs",
55+
"url": "https://github.com/clue-labs/socket"
56+
}
57+
]
5258
}

examples/11-client-http-connect-proxy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
$proxy = new HttpConnectClient('127.0.0.1:8080', new Connector());
1818

1919
// create a Browser object that uses the HTTP CONNECT proxy client for connections
20-
$connector = new Connector(null, array(
20+
$connector = new Connector(array(
2121
'tcp' => $proxy,
2222
'dns' => false
2323
));

examples/12-client-socks-proxy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
$proxy = new SocksClient('127.0.0.1:1080', new Connector());
1515

1616
// create a Browser object that uses the SOCKS proxy client for connections
17-
$connector = new Connector(null, array(
17+
$connector = new Connector(array(
1818
'tcp' => $proxy,
1919
'dns' => false
2020
));

examples/13-client-ssh-proxy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
$proxy = new SshSocksConnector(isset($argv[1]) ? $argv[1] : 'localhost:22', Loop::get());
1414

1515
// create a Browser object that uses the SSH proxy client for connections
16-
$connector = new Connector(null, array(
16+
$connector = new Connector(array(
1717
'tcp' => $proxy,
1818
'dns' => false
1919
));

examples/51-server-hello-world.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
);
1616
});
1717

18-
$socket = new React\Socket\Server(isset($argv[1]) ? $argv[1] : '0.0.0.0:0');
18+
$socket = new React\Socket\SocketServer(isset($argv[1]) ? $argv[1] : '0.0.0.0:0');
1919
$http->listen($socket);
2020

2121
echo 'Listening on ' . str_replace('tcp:', 'http:', $socket->getAddress()) . PHP_EOL;

examples/52-server-count-visitors.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
);
1717
});
1818

19-
$socket = new React\Socket\Server(isset($argv[1]) ? $argv[1] : '0.0.0.0:0');
19+
$socket = new React\Socket\SocketServer(isset($argv[1]) ? $argv[1] : '0.0.0.0:0');
2020
$http->listen($socket);
2121

2222
echo 'Listening on ' . str_replace('tcp:', 'http:', $socket->getAddress()) . PHP_EOL;

examples/53-server-whatsmyip.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
);
1818
});
1919

20-
$socket = new React\Socket\Server(isset($argv[1]) ? $argv[1] : '0.0.0.0:0');
20+
$socket = new React\Socket\SocketServer(isset($argv[1]) ? $argv[1] : '0.0.0.0:0');
2121
$http->listen($socket);
2222

2323
echo 'Listening on ' . str_replace('tcp:', 'http:', $socket->getAddress()) . PHP_EOL;

examples/54-server-query-parameter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
);
2525
});
2626

27-
$socket = new React\Socket\Server(isset($argv[1]) ? $argv[1] : '0.0.0.0:0');
27+
$socket = new React\Socket\SocketServer(isset($argv[1]) ? $argv[1] : '0.0.0.0:0');
2828
$http->listen($socket);
2929

3030
echo 'Listening on ' . str_replace('tcp:', 'http:', $socket->getAddress()) . PHP_EOL;

examples/55-server-cookie-handling.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
);
3131
});
3232

33-
$socket = new React\Socket\Server(isset($argv[1]) ? $argv[1] : '0.0.0.0:0');
33+
$socket = new React\Socket\SocketServer(isset($argv[1]) ? $argv[1] : '0.0.0.0:0');
3434
$http->listen($socket);
3535

3636
echo 'Listening on ' . str_replace('tcp:', 'http:', $socket->getAddress()) . PHP_EOL;

0 commit comments

Comments
 (0)