MyGit

friends-of-reactphp/zmq

Fork: 49 Star: 248 (更新于 2024-10-29 13:56:34)

license: MIT

Language: PHP .

ZeroMQ bindings for ReactPHP.

最后发布版本: v0.4.0 ( 2018-05-18 23:30:27)

GitHub网址

React/ZMQ

ZeroMQ bindings for React.

Build Status

Install

The recommended way to install react/zmq is through composer.

composer require react/zmq

Example

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();

Todo

  • Integration tests
  • Buffer limiting
  • Do not push messages if no listener

Tests

To run the test suite, you need PHPUnit.

$ phpunit

License

MIT, see LICENSE.

最近版本更新:(数据更新于 2024-10-04 01:44:39)

2018-05-18 23:30:27 v0.4.0

2014-05-26 01:55:58 v0.3.0

friends-of-reactphp/zmq同语言 PHP最近更新仓库

2024-11-13 22:53:21 symfony/var-dumper

2024-11-11 23:40:24 coollabsio/coolify

2024-11-06 20:45:55 schmittjoh/JMSSerializerBundle

2024-11-06 18:04:49 symfony/symfony

2024-10-31 21:37:53 filamentphp/filament

2024-10-11 03:27:29 odan/slim4-skeleton