Diogo Cordeiro 96c4e57ac0 Add gs-wsRealtime by Chimo | %!s(int64=5) %!d(string=hai) anos | |
---|---|---|
.. | ||
examples | %!s(int64=5) %!d(string=hai) anos | |
src | %!s(int64=5) %!d(string=hai) anos | |
tests | %!s(int64=5) %!d(string=hai) anos | |
.gitignore | %!s(int64=5) %!d(string=hai) anos | |
.travis.yml | %!s(int64=5) %!d(string=hai) anos | |
CHANGELOG.md | %!s(int64=5) %!d(string=hai) anos | |
LICENSE | %!s(int64=5) %!d(string=hai) anos | |
README.md | %!s(int64=5) %!d(string=hai) anos | |
composer.json | %!s(int64=5) %!d(string=hai) anos | |
composer.lock | %!s(int64=5) %!d(string=hai) anos | |
phpunit.xml.dist | %!s(int64=5) %!d(string=hai) anos |
ZeroMQ bindings for React.
The recommended way to install react/zmq is through composer.
{
"require": {
"react/zmq": "0.2.*|0.3.*"
}
}
And don't forget to autoload:
<?php
require 'vendor/autoload.php';
Here is an example of a push socket:
<?php
$loop = React\EventLoop\Factory::create();
$context = new React\ZMQ\Context($loop);
$push = $context->getSocket(ZMQ::SOCKET_PUSH);
$push->connect('tcp://127.0.0.1:5555');
$i = 0;
$loop->addPeriodicTimer(1, function () use (&$i, $push) {
$i++;
echo "sending $i\n";
$push->send($i);
});
$loop->run();
And the pull socket that goes with it:
<?php
$loop = React\EventLoop\Factory::create();
$context = new React\ZMQ\Context($loop);
$pull = $context->getSocket(ZMQ::SOCKET_PULL);
$pull->bind('tcp://127.0.0.1:5555');
$pull->on('error', function ($e) {
var_dump($e->getMessage());
});
$pull->on('message', function ($msg) {
echo "Received: $msg\n";
});
$loop->run();
To run the test suite, you need PHPUnit.
$ phpunit
MIT, see LICENSE.