コード例 #1
0
ファイル: AMQPChannel.php プロジェクト: moodtraffic/yii2-amqp
 public function __construct($connection, $channel_id = null, $auto_decode = true)
 {
     if ($channel_id == null) {
         $channel_id = $connection->get_free_channel_id();
     }
     parent::__construct($connection, $channel_id);
     if ($this->debug) {
         MiscHelper::debug_msg("using channel_id: " . $channel_id);
     }
     $this->default_ticket = 0;
     $this->is_open = false;
     $this->active = true;
     // Flow control
     $this->alerts = array();
     $this->callbacks = array();
     $this->auto_decode = $auto_decode;
     $this->x_open();
 }
コード例 #2
0
 public function __construct($user, $password, $vhost = "/", $insist = false, $login_method = "AMQPLAIN", $login_response = null, $locale = "en_US", AbstractIO $io)
 {
     // save the params for the use of __clone
     $this->construct_params = func_get_args();
     if ($user && $password) {
         $login_response = new AMQPWriter();
         $login_response->write_table(array("LOGIN" => array('S', $user), "PASSWORD" => array('S', $password)));
         $login_response = substr($login_response->getvalue(), 4);
         //Skip the length
     } else {
         $login_response = null;
     }
     $d = self::$LIBRARY_PROPERTIES;
     while (true) {
         $this->channels = array();
         // The connection object itself is treated as channel 0
         parent::__construct($this, 0);
         $this->channel_max = 65535;
         $this->frame_max = 131072;
         $this->io = $io;
         $this->input = new AMQPReader(null, $this->io);
         $this->write($this->amqp_protocol_header);
         $this->wait(array($this->waitHelper->get_wait('connection.start')));
         $this->x_start_ok($d, $login_method, $login_response, $locale);
         $this->wait_tune_ok = true;
         while ($this->wait_tune_ok) {
             $this->wait(array($this->waitHelper->get_wait('connection.secure'), $this->waitHelper->get_wait('connection.tune')));
         }
         $host = $this->x_open($vhost, "", $insist);
         if (!$host) {
             return;
             // we weren't redirected
         }
         // we were redirected, close the socket, loop and try again
         $this->close_socket();
     }
 }