コード例 #1
0
ファイル: Exception.php プロジェクト: swk/bluebox
 public function __construct($reply_code, $reply_text, $method_sig)
 {
     parent::__construct(NULL, 0);
     $this->amqp_reply_code = $reply_code;
     $this->amqp_reply_text = $reply_text;
     $this->amqp_method_sig = $method_sig;
     $ms = AMQP_Core::methodSig($method_sig);
     if (array_key_exists($ms, AMQP_Core::$METHOD_NAME_MAP)) {
         $mn = AMQP_Core::$METHOD_NAME_MAP[$ms];
     } else {
         $mn = "";
     }
     $this->args = array($reply_code, $reply_text, $method_sig, $mn);
 }
コード例 #2
0
ファイル: Channel.php プロジェクト: swk/bluebox
 public function __construct($connection, $channel_id = NULL, $auto_decode = true)
 {
     if ($channel_id == NULL) {
         $channel_id = $connection->get_free_channel_id();
     }
     self::debug_msg("using channel_id: " . $channel_id);
     parent::__construct($connection, $channel_id);
     $this->METHOD_MAP = AMQP_Channel::$METHOD_MAP;
     $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();
 }
コード例 #3
0
ファイル: Connection.php プロジェクト: swk/bluebox
 public function __construct($host, $port, $user, $password, $vhost = "/", $insist = false, $login_method = "AMQPLAIN", $login_response = NULL, $locale = "en_US", $connection_timeout = 10, $read_write_timeout = 10)
 {
     $this->METHOD_MAP = AMQP_Connection::$METHOD_MAP;
     if ($user && $password) {
         $login_response = new AMQP_Writer();
         $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 = AMQP_Connection::$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;
         $errstr = $errno = NULL;
         $this->sock = NULL;
         if (!($this->sock = fsockopen($host, $port, $errno, $errstr, $connection_timeout))) {
             throw new Exception("Error Connecting to server({$errno}): {$errstr} ");
         }
         stream_set_timeout($this->sock, $read_write_timeout);
         stream_set_blocking($this->sock, 1);
         $this->input = new AMQP_Reader(null, $this->sock);
         $this->write(AMQP_Connection::$AMQP_PROTOCOL_HEADER);
         $this->wait(array("10,10"));
         $this->x_start_ok($d, $login_method, $login_response, $locale);
         $this->wait_tune_ok = true;
         while ($this->wait_tune_ok) {
             $this->wait(array("10,20", "10,30"));
         }
         $host = $this->x_open($vhost, "", $insist);
         if (!$host) {
             return;
         }
         // we weren't redirected
         // we were redirected, close the socket, loop and try again
         self::debug_msg("closing socket");
         @fclose($this->sock);
         $this->sock = NULL;
     }
 }