Esempio n. 1
0
 /**
  * @param Connection $connection
  * @param null       $channelId
  * @param bool       $autoDecode
  */
 public function __construct($connection, $channelId = null, $autoDecode = true)
 {
     $this->frameBuilder = new FrameBuilder();
     if ($channelId == null) {
         $channelId = $connection->getFreeChannelId();
     }
     parent::__construct($connection, $channelId);
     if ($this->debug) {
         Helper::debugMsg(sprintf('using channel_id: %s', $channelId));
     }
     $this->autoDecode = $autoDecode;
     $this->xOpen();
 }
Esempio n. 2
0
 /**
  *
  */
 protected function connect()
 {
     $login_response = $this->getLoginResponse();
     while (true) {
         $this->channels = array();
         /*
          * The connection object itself is treated as channel 0
          */
         parent::__construct($this, 0);
         $this->createSocket();
         $this->input = new Reader(null, $this->sock);
         $this->write(self::$amqpProtocolHeader);
         $this->wait(array("10,10"));
         $this->xStartOk(self::$libraryProperties, $this->options['login_method'], $login_response, $this->options['locale']);
         while ($this->waitTuneOk) {
             $this->wait(array("10,20", "10,30"));
         }
         $vhost = preg_replace('/^\\//', null, $this->uri['path']) ?: '/';
         $host = $this->xOpen($vhost, '', $this->options['insist']);
         if (!$host) {
             return;
             // we weren't redirected
         }
         $this->closeSocket();
         return;
     }
 }