/** * @param ProtocolInterface * @return bool */ protected function handleReceiveRequest(ProtocolInterface $protocol) { if ($protocol->getType() === Channel::TYPE_REQ && $protocol->getDestination() === $this->name) { $pid = $protocol->getPid(); $timestamp = $protocol->getTimestamp(); $now = $this->getTime(); if ($timestamp <= $now || $this->existsResponse($pid)) { return true; } $timestamp -= 5000.0; $this->addResponse($pid, $this->createResponse($pid, $protocol->getOrigin(), $timestamp, $timestamp - $now)); } return false; }
/** * @param string $name * @param ProtocolInterface $message * @param int $flags * @return bool */ protected function handleSendAsync($name, $message, $flags = Channel::MODE_DEFAULT) { if ($message->getType() === '') { $message->setType(Channel::TYPE_SND); } if ($message->getDestination() === '') { $message->setDestination($name); } return $this->getOutput()->handle($name, $message, $flags); }
/** * @param string $name * @param ProtocolInterface $protocol * @return bool */ public function __invoke($name, ProtocolInterface $protocol) { return StringSupport::match($this->name, $protocol->getDestination()); }