1 | 2 | simandl | <?php |
2 | | | |
3 | | | namespace Phem\Libraries\MessageBus; |
4 | | | |
5 | | | use React\EventLoop\LoopInterface; |
6 | | | use React\ZMQ\Context; |
7 | | | |
8 | | | /** |
9 | | | * @author Jakub PetrĹžĂlka <petrzilka@czweb.net> |
10 | | | */ |
11 | | | class ZMQPuller extends WebsocketPuller |
12 | | | { |
13 | | | |
14 | | | protected $server; |
15 | | | |
16 | | | public function __construct(LoopInterface $loop, MessageBus $msgBus) |
17 | | | { |
18 | | | $context = new Context($loop); |
19 | | | $this->server = $context->getSocket(\ZMQ::SOCKET_PULL); |
20 | | | $this->server->on('message', array($msgBus, 'onNotify')); |
21 | | | } |
22 | | | |
23 | | | public function listen($ip, $port) |
24 | | | { |
25 | | | $this->server->bind('tcp://'.$ip.':'.$port); |
26 | | | } |
27 | | | |
28 | | | } |