Exemplo n.º 1
0
 /**
  * @param LocationInterface $location
  * @param Request           $request
  *
  * @return Response\Promise
  *
  * @throws \Exception
  */
 public function call(LocationInterface $location, Request $request)
 {
     $interaction = Interaction::call($location, $request);
     $this->profile->add($interaction);
     $interaction->start();
     try {
         $promise = $this->driver->call($location, $request);
     } catch (\Exception $exception) {
         $interaction->fail($exception);
         $interaction->stop();
         throw $exception;
     }
     $interaction->stop();
     return new Response\Promise(function ($timeout) use($promise, $interaction) {
         $interaction->start();
         try {
             $response = $promise->resolve($timeout);
         } catch (\Exception $exception) {
             $interaction->stop();
             $interaction->fail($exception);
             throw $exception;
         }
         $interaction->reply($response);
         $interaction->stop();
         return $response;
     });
 }