예제 #1
0
 public function testSend()
 {
     $context = new \ZMQContext();
     $endpoint = "inproc://zmq_publisher";
     $publisher = new Publisher($endpoint, $context);
     $sub1 = $this->createSubscriber($context, $endpoint);
     $sub2 = $this->createSubscriber($context, $endpoint);
     $msgOut = "azaza";
     $publisher->send($msgOut);
     $sub1->recv();
     $sub2->recv();
     $this->assertEquals($sub1->parts(), 2);
     $this->assertEquals($sub1->body(), $msgOut);
     $this->assertEquals($sub2->parts(), 2);
     $this->assertEquals($sub2->body(), $msgOut);
 }
예제 #2
0
파일: publisher.php 프로젝트: limitium/zmq
<?php

require './../../vendor/autoload.php';
use limitium\zmq\Publisher;
$publisher = new Publisher('tcp://127.0.0.1:6666', null, true);
while (true) {
    $publisher->send(rand());
    sleep(1);
}