承接 react/zmq 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

react/zmq

最新稳定版本:v0.4.0

Composer 安装命令:

composer require react/zmq

包简介

ZeroMQ bindings for React.

关键字:

README 文档

README

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.

统计信息

  • 总下载量: 1.62M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 251
  • 点击次数: 1
  • 依赖项目数: 47
  • 推荐数: 8

GitHub 信息

  • Stars: 248
  • Watchers: 18
  • Forks: 49
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2012-05-26