/**
  * Start transport provider
  *
  * @param \Thruway\Peer\AbstractPeer $peer
  * @param \React\EventLoop\LoopInterface $loop
  */
 public function startTransportProvider(AbstractPeer $peer, LoopInterface $loop)
 {
     Logger::info($this, "Starting Transport");
     $this->peer = $peer;
     $this->loop = $loop;
     $this->connector = new \Ratchet\Client\Factory($this->loop);
     $this->connector->__invoke($this->URL, ['wamp.2.json'])->then(function (WebSocket $conn) {
         Logger::info($this, "Pawl has connected");
         $transport = new PawlTransport($conn, $this->loop);
         $transport->setSerializer(new JsonSerializer());
         $transport->setTrusted($this->trusted);
         $this->peer->onOpen($transport);
         $conn->on('message', function ($msg) use($transport) {
             Logger::debug($this, "Received: {$msg}");
             try {
                 $this->peer->onMessage($transport, $transport->getSerializer()->deserialize($msg));
             } catch (DeserializationException $e) {
                 Logger::warning($this, "Deserialization exception occurred.");
             } catch (\Exception $e) {
                 Logger::warning($this, "Exception occurred during onMessage: " . $e->getMessage());
             }
         });
         $conn->on('close', function ($conn) {
             Logger::info($this, "Pawl has closed");
             $this->peer->onClose('close');
         });
         $conn->on('pong', function ($frame, $ws) use($transport) {
             $transport->onPong($frame, $ws);
         });
     }, function ($e) {
         $this->peer->onClose('unreachable');
         Logger::info($this, "Could not connect: {$e->getMessage()}");
         // $this->loop->stop();
     });
 }