Пример #1
0
 public function testSendReceive()
 {
     // Create the mailbox
     $receiver = new Receiver('/tmp/ipc_test');
     // Send a message to it
     $sender = new Sender('/tmp/ipc_test');
     $sender->send("Test message");
     // Make sure we don't wait for the message, incase something is wrong.
     $receiver->waitForMessage(false);
     // Receive the message
     $msg = null;
     $receiver->run(function ($message, $type) use(&$msg) {
         $msg = $message;
         return false;
     });
     // Check the message
     $this->assertEquals("Test message", $msg);
 }
Пример #2
0
<?php

require_once __DIR__ . '/../src/Receiver.php';
require_once __DIR__ . '/../src/Exception.php';
use Blamh\IPC\Receiver;
// Create the mailbox
$receiver = new Receiver('/tmp/ipc_test');
// Receive the message
$receiver->run(function ($message, $type) {
    print "Receiving: {$message}\n";
});