Example #1
0
 public function testPipio()
 {
     $messages = [];
     $pipio = new Pipio();
     $pipio->on('SomeEvent', null, function ($event, $message) use($pipio) {
         $pipio->emit('OtherEvent', 'Hello');
     });
     $pipio->on('OtherEvent', null, function ($event, $message) use(&$messages) {
         $messages[] = $message;
     });
     $pipio->emit('SomeEvent');
     $pipio->emit('OtherEvent', 'Goodbye');
     $pipio->wait(0);
     $this->assertEquals(count($messages), 2);
     $this->assertTrue(in_array('Hello', $messages));
     $this->assertTrue(in_array('Goodbye', $messages));
 }
Example #2
0
<?php

require_once __DIR__ . '/../../vendor/autoload.php';
use Pipio\Pipio;
list($script, $host, $port, $user, $pass, $event) = $argv;
$connection = new \PhpAmqpLib\Connection\AMQPStreamConnection($host, $port, $user, $pass);
$channel = $connection->channel();
$pipio = new Pipio();
$pipio->addConsumer(new \Pipio\Consumer\Amqp($channel));
$pipio->on($event, null, function ($message) {
    echo $message;
});
$pipio->wait();
$connection->close();
Example #3
0
<?php

require_once __DIR__ . '/../../vendor/autoload.php';
use Pipio\Pipio;
list($script, $host, $port, $user, $pass, $event, $message) = $argv;
$connection = new \PhpAmqpLib\Connection\AMQPStreamConnection($host, $port, $user, $pass);
$channel = $connection->channel();
$pipio = new Pipio();
$pipio->addProducer(new \Pipio\Producer\Amqp($channel));
$pipio->emit($event, $message);
$connection->close();