Hi to all,
sorry if my question can seems stupid but I'm not so much expert in Ratchet and a little bit newbie with it.
I already have a Ratchet IoServer running that serve some clients (calling it Server 1 from now on it listen on port 8082 for clients to connect).
What I need is to let the Server 1 to connect as a client too to another Ratchet IoSever (calling Server 2 from now on it listen on port 8182 for Server 1 to connect).
Server 1 should send messages coming from its clients to Server 2 and/or listen for messages coming from Server 2 and deliver to its clients connected directly to it (Server 1).
Now I'm trying to do some tests with something like:
****** Server 1 Client Part Start **********
$loop_client = React\EventLoop\Factory::create();
$client = stream_socket_client('tcp://127.0.0.1:8182');
$conn_client = new React\Socket\Connection($client, $loop_client);
$conn_client->pipe(new React\Stream\Stream(STDOUT, $loop_client));
$conn_client->write("Hello World!\n");
$loop_client->run();
******* Server 1 Client Part Stop ***********
****** Server 1 Server Part Start **********
$app=new App();
$loop = React\EventLoop\Factory::create();
$socket = new React\Socket\Server($loop);
$socket->listen('8082', '127.0.0.1');
$server = new IoServer(
$app,
$socket,
$loop
);
$server->run();
******* Server 1 Server Part Stop ***********
My problem is that the script never reach the server part , I think because the client $loop_client->run() part is blocking.
If i move it after the $server->run() the server run correctly, the connection to Server 2 is made but the message "Hello World" is never received on the Server 2, I think because the $server->run() is blocking.
Can you help me to reach this goal?
Thank you in advance,
Bye Bye
Marcello