Пример #1
0
 /**
  * @param \PhpAmqpLib\Connection\AbstractConnection $connection
  * @param                                       $channel_id
  */
 public function __construct(AbstractConnection $connection, $channel_id)
 {
     $this->connection = $connection;
     $this->channel_id = $channel_id;
     $connection->channels[$channel_id] = $this;
     $this->frame_queue = array();
     // Lower level queue for frames
     $this->method_queue = array();
     // Higher level queue for methods
     $this->auto_decode = false;
     $this->debug = defined('AMQP_DEBUG') ? AMQP_DEBUG : false;
     $this->protocolVersion = defined('AMQP_PROTOCOL') ? AMQP_PROTOCOL : '0.9.1';
     switch ($this->protocolVersion) {
         case '0.9.1':
             self::$PROTOCOL_CONSTANTS_CLASS = 'PhpAmqpLib\\Wire\\Constants091';
             $c = self::$PROTOCOL_CONSTANTS_CLASS;
             $this->amqp_protocol_header = $c::$AMQP_PROTOCOL_HEADER;
             $this->protocolWriter = new Protocol091();
             $this->waitHelper = new Wait091();
             $this->methodMap = new MethodMap091();
             break;
         case '0.8':
             self::$PROTOCOL_CONSTANTS_CLASS = 'PhpAmqpLib\\Wire\\Constants080';
             $c = self::$PROTOCOL_CONSTANTS_CLASS;
             $this->amqp_protocol_header = $c::$AMQP_PROTOCOL_HEADER;
             $this->protocolWriter = new Protocol080();
             $this->waitHelper = new Wait080();
             $this->methodMap = new MethodMap080();
             break;
         default:
             throw new AMQPRuntimeException('Protocol: ' . $this->protocolVersion . ' not implemented.');
     }
 }
Пример #2
0
 /**
  * @param AbstractConnection $connection
  * @param $channel_id
  * @throws \PhpAmqpLib\Exception\AMQPRuntimeException
  */
 public function __construct(AbstractConnection $connection, $channel_id)
 {
     $this->connection = $connection;
     $this->channel_id = $channel_id;
     $connection->channels[$channel_id] = $this;
     $this->frame_queue = array();
     // Lower level queue for frames
     $this->method_queue = array();
     // Higher level queue for methods
     $this->auto_decode = false;
     $this->msg_property_reader = new AMQPReader(null);
     $this->wait_content_reader = new AMQPReader(null);
     $this->dispatch_reader = new AMQPReader(null);
     $this->protocolVersion = self::getProtocolVersion();
     switch ($this->protocolVersion) {
         case self::PROTOCOL_091:
             self::$PROTOCOL_CONSTANTS_CLASS = 'PhpAmqpLib\\Wire\\Constants091';
             $c = self::$PROTOCOL_CONSTANTS_CLASS;
             $this->debug = new DebugHelper($c);
             $this->amqp_protocol_header = $c::$AMQP_PROTOCOL_HEADER;
             $this->protocolWriter = new Protocol091();
             $this->waitHelper = new Wait091();
             $this->methodMap = new MethodMap091();
             break;
         case self::PROTOCOL_080:
             self::$PROTOCOL_CONSTANTS_CLASS = 'PhpAmqpLib\\Wire\\Constants080';
             $c = self::$PROTOCOL_CONSTANTS_CLASS;
             $this->debug = new DebugHelper($c);
             $this->amqp_protocol_header = $c::$AMQP_PROTOCOL_HEADER;
             $this->protocolWriter = new Protocol080();
             $this->waitHelper = new Wait080();
             $this->methodMap = new MethodMap080();
             break;
         default:
             throw new AMQPRuntimeException(sprintf('Protocol: %s not implemented.', $this->protocolVersion));
             break;
     }
 }