/** * @param ZmqEvent $value * @return mixed */ public function onNext($value) { $ack = new Event('/zmq/ack', [], ['id' => $value->getLabel('id')]); return $this->socket->send($ack)->map(function () use($value) { return $value; }); }
/** * @param ZmqEvent $event * @return mixed */ public function __invoke($event) { return Observable::create(function (ObserverInterface $observer) use($event) { $id = $event->getLabel('id'); $req = new ZmqRequest(); $req->subscribe($observer); $disposable = $this->source->filter(function (Event $event) use($id) { return $event->hasLabel('id', $id); })->take(1)->subscribe($req); $req->subscribeCallback(null, null, function () use($disposable) { $disposable->dispose(); }); return new CallbackDisposable(function () use($disposable) { $disposable->dispose(); }); }); }