Esempio n. 1
0
 public function testRoundtrip()
 {
     $pm = new ProtocolMessage();
     $pm->setActions(array('service1', 'service2'));
     $pm2 = ProtocolMessage::fromMessage($pm->toMessage());
     $this->assertEquals($pm, $pm2);
 }
 public function testTheMessageIsSerializableToItself()
 {
     $pm = new ProtocolMessage();
     $pm->setActions(array('service1', 'service2'));
     $pm2 = ProtocolMessage::fromMessage($pm->toMessage());
     $this->assertEquals($pm, $pm2);
 }
 /**
  * Handles a Message from the Service Handler.
  *
  * @param MessageInterface $msg
  */
 public function onServiceMessage(MessageInterface $msg)
 {
     $this->serviceStreamReady = true;
     $this->getLogger()->debug('Received Service Message of Type: ' . get_class($msg));
     if ($msg instanceof ActionListResponse) {
         $actions = $msg->getActions();
         $this->getLogger()->debug('The action list is: ' . implode(', ', $actions) . '.');
         $this->worker->setActions($actions);
         $reply = new Register();
         $reply->setActions($actions);
         $this->sendToWorkerHandler($reply);
         unset($reply);
         return;
     }
     if ($msg instanceof ExecuteJobResponse) {
         $requestId = $msg->getRequestId();
         $result = $msg->getResult();
         $this->getLogger()->debug('Result for: ' . $requestId . ': ' . $result);
         $this->worker->setResult($requestId, $result);
         return;
     }
     $this->getLogger()->error('Unknown service response: ' . get_class($msg) . '.');
 }