Example #1
0
 /**
  * @param PromiseInterface $promise
  * @return PromiseInterface
  */
 protected function send(PromiseInterface $promise)
 {
     $pid = $this->protocol->getPid();
     $origin = $this->protocol->getOrigin();
     $message = $this->message;
     $channel = $this->channel;
     if ($message instanceof Exception) {
         $answer = $channel->createProtocol($message->getMessage())->setPid($pid, true)->setException(get_class($message), true);
     } else {
         $answer = $channel->createProtocol($message)->setPid($pid, true);
     }
     $this->channel->send($origin, $answer, Channel::MODE_BUFFER_ONLINE);
     return $promise->resolve();
 }
Example #2
0
 /**
  * @param string $name
  * @param ChannelProtocolInterface $protocol
  * @return bool
  */
 public function __invoke($name, ChannelProtocolInterface $protocol)
 {
     return $protocol->getPid() === $this->pid;
 }