22
33namespace EProcess \Adapter ;
44
5- use EProcess \ Behaviour \ UniversalSerializer ;
6- use EProcess \MessengerFactory ;
5+ use UniversalSerializer \ UniversalSerializerTrait ;
6+ use EMessenger \MessengerFactory ;
77use EProcess \Stream \FullDrainStream ;
88use React \ChildProcess \Process ;
99use Symfony \Component \Process \PhpExecutableFinder ;
1010
1111class ChildProcess extends BaseAdapter
1212{
13- use UniversalSerializer ;
13+ use UniversalSerializerTrait ;
1414
1515 private $ script = <<<PHP
1616<?php
@@ -19,15 +19,15 @@ class ChildProcess extends BaseAdapter
1919
2020set_time_limit(0);
2121
22- use EProcess\MessengerFactory;
22+ use EMessenger\MessengerFactory;
23+ use EMessenger\Transport\UnixTransport;
2324use EProcess\Application\ApplicationFactory;
2425use React\EventLoop\Factory;
2526
2627\$loop = Factory::create();
2728
2829\$messenger = MessengerFactory::client(
29- '%s',
30- \$loop
30+ new UnixTransport( \$loop, '%s')
3131);
3232
3333\$application = ApplicationFactory::create('%s');
@@ -36,7 +36,7 @@ class ChildProcess extends BaseAdapter
3636\$application->loop( \$loop);
3737\$application->data( \$application->unserialize(base64_decode('%s')));
3838
39- \$messenger->emit ('initialized', true);
39+ \$messenger->send ('initialized', true);
4040
4141try {
4242 \$application->run();
@@ -56,13 +56,13 @@ public function create($class, array $data = [])
5656 throw new \RuntimeException ('Unable to find the PHP executable. ' );
5757 }
5858
59- $ unix = $ this ->createUnixSocket ();
60- $ messenger = MessengerFactory::server ($ unix , $ this -> loop );
59+ $ transport = $ this ->createUnixTransport ();
60+ $ messenger = MessengerFactory::server ($ transport );
6161
6262 $ script = sprintf (
6363 $ this ->script ,
6464 EPROCESS_AUTOLOAD ,
65- $ unix ,
65+ $ this -> getUnixSocketAddress () ,
6666 $ class ,
6767 base64_encode ($ this ->serialize ($ data ))
6868 );
@@ -77,15 +77,15 @@ public function create($class, array $data = [])
7777
7878 $ this ->process ->stdin ->write ($ script );
7979
80- $ this ->process ->stdin ->on ('full-drain ' , function () {
80+ $ this ->process ->stdin ->on ('full-drain ' , function () {
8181 $ this ->process ->stdin ->close ();
8282 });
8383
84- $ this ->process ->stdout ->on ('data ' , function ($ data ) {
84+ $ this ->process ->stdout ->on ('data ' , function ($ data ) {
8585 echo $ data ;
8686 });
8787
88- $ this ->process ->stderr ->on ('data ' , function ($ data ) {
88+ $ this ->process ->stderr ->on ('data ' , function ($ data ) {
8989 echo $ data ;
9090 });
9191
0 commit comments