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:
343
343
344
344
``` php
345
345
$connection->on('data', function ($chunk) {
346
- echo $data ;
346
+ echo $chunk ;
347
347
});
348
348
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 () {
350
358
echo 'closed';
351
359
});
352
360
Original file line number Diff line number Diff line change 7
7
"php" : " >=5.3.0" ,
8
8
"evenement/evenement" : " ~2.0|~1.0" ,
9
9
"react/event-loop" : " 0.4.*|0.3.*" ,
10
- "react/stream" : " ^0.4.5" ,
10
+ "react/stream" : " ^0.6 || ^0.5 || ^0. 4.5" ,
11
11
"react/promise" : " ^2.0 || ^1.1"
12
12
},
13
13
"require-dev" : {
Original file line number Diff line number Diff line change 20
20
* use React's SocketClient component instead.
21
21
*
22
22
* 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).
24
50
*
25
51
* @see DuplexStreamInterface
26
52
*/
You can’t perform that action at this time.
0 commit comments