28 lines
692 B
PHP
28 lines
692 B
PHP
<?php
|
|
|
|
require_once __DIR__."/../vendor/autoload.php";
|
|
|
|
use NoccyLabs\Ipc\Interop\Bus\Master;
|
|
|
|
|
|
$master = new Master();
|
|
|
|
$client1 = $master->createClient();
|
|
$client1->addListener(function ($msg) use ($client1) {
|
|
printf("channel1: %s\n", json_encode($msg));
|
|
$client1->call("/channel2/hello", "channel1")->then(function ($ret) {
|
|
printf("channel1: %s\n", $ret);
|
|
});
|
|
});
|
|
$client2 = $master->createClient();
|
|
$client2->addListener(function ($msg) {
|
|
printf("channel2: %s\n", json_encode($msg));
|
|
});
|
|
$client2->export("/channel2/hello", function ($name) {
|
|
return sprintf("Hello, %s", $name);
|
|
});
|
|
|
|
$client1->send("hello world");
|
|
for ($n = 0; $n < 10; $n++) {
|
|
sleep(1);
|
|
} |