File tree Expand file tree Collapse file tree 3 files changed +38
-4
lines changed
Expand file tree Collapse file tree 3 files changed +38
-4
lines changed Original file line number Diff line number Diff line change @@ -343,10 +343,18 @@ you can use any of its events and methods as usual:
343343
344344``` php
345345$connection->on('data', function ($chunk) {
346- echo $data ;
346+ echo $chunk ;
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
Original file line number Diff line number Diff line change 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" : {
Original file line number Diff line number Diff line change 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 $chunk;
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 */
You can’t perform that action at this time.
0 commit comments