Skip to content

Commit 57c25d4

Browse files
committed
Forward compatibility with Stream v0.5 and upcoming v0.6
1 parent 26b32eb commit 57c25d4

File tree

3 files changed

+37
-3
lines changed

3 files changed

+37
-3
lines changed

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,15 @@ $connection->on('data', function ($chunk) {
346346
echo $data;
347347
});
348348

349-
$conenction->on('close', function () {
349+
$connection->on('end', function () {
350+
echo 'ended';
351+
});
352+
353+
$connection->on('error', function (Exception $e) {
354+
echo 'error: ' . $e->getMessage();
355+
});
356+
357+
$connection->on('close', function () {
350358
echo 'closed';
351359
});
352360

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"php": ">=5.3.0",
88
"evenement/evenement": "~2.0|~1.0",
99
"react/event-loop": "0.4.*|0.3.*",
10-
"react/stream": "^0.4.5",
10+
"react/stream": "^0.6 || ^0.5 || ^0.4.5",
1111
"react/promise": "^2.0 || ^1.1"
1212
},
1313
"require-dev": {

src/ConnectionInterface.php

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,33 @@
2020
* use React's SocketClient component instead.
2121
*
2222
* Because the `ConnectionInterface` implements the underlying
23-
* `DuplexStreamInterface` you can use any of its events and methods as usual.
23+
* `DuplexStreamInterface` you can use any of its events and methods as usual:
24+
*
25+
* ```php
26+
* $connection->on('data', function ($chunk) {
27+
* echo $data;
28+
* });
29+
*
30+
* $connection->on('end', function () {
31+
* echo 'ended';
32+
* });
33+
*
34+
* $connection->on('error', function (Exception $e) {
35+
* echo 'error: ' . $e->getMessage();
36+
* });
37+
*
38+
* $connection->on('close', function () {
39+
* echo 'closed';
40+
* });
41+
*
42+
* $connection->write($data);
43+
* $connection->end($data = null);
44+
* $connection->close();
45+
* // …
46+
* ```
47+
*
48+
* For more details, see the
49+
* [`DuplexStreamInterface`](https://github.com/reactphp/stream#duplexstreaminterface).
2450
*
2551
* @see DuplexStreamInterface
2652
*/

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy