PhpAmqpLib/Channel/AbstractChannel.php
public function wait($allowed_methods = null, $non_blocking = false, $timeout = 0)
    {
        $this->debug->debug_allowed_methods($allowed_methods);

        $deferred = $this->process_deferred_methods($allowed_methods);
        if ($deferred['dispatch'] === true) {
            return $this->dispatch_deferred_method($deferred['queued_method']);
        }

        // timeouts must be deactivated for non-blocking actions
        if (true === $non_blocking) {
            $timeout = null;
        }

        // No deferred methods?  wait for new ones
        while (true) {
            try {
                list($frame_type, $payload) = $this->next_frame($timeout);
            } catch (AMQPNoDataException $e) {
                // no data ready for non-blocking actions - stop and exit
                break;
            } catch (AMQPConnectionClosedException $exception) {
                if ($this instanceof AMQPChannel) {
                    $this->do_close();
                }
                throw $exception;
            }

            $this->validate_method_frame($frame_type);
            $this->validate_frame_payload($payload);

            $method_sig = $this->build_method_signature($payload);
            $args = $this->extract_args($payload);

            $this->debug->debug_method_signature('> %s', $method_sig);

            $amqpMessage = $this->maybe_wait_for_content($method_sig);

            if ($this->should_dispatch_method($allowed_methods, $method_sig)) {
                return $this->dispatch($method_sig, $args, $amqpMessage);
            }

            // Wasn't what we were looking for? save it for later
            $this->debug->debug_method_signature('Queueing for later: %s', $method_sig);
            $this->method_queue[] = array($method_sig, $args, $amqpMessage);

            if ($non_blocking) {
                break;
            }
        }
    }
public function wait($allowed_methods = null, $non_blocking = false, $timeout = 0)
    {
        $this->debug->debug_allowed_methods($allowed_methods);

        $deferred = $this->process_deferred_methods($allowed_methods);
        if ($deferred['dispatch'] === true) {
            return $this->dispatch_deferred_method($deferred['queued_method']);
        }

        // timeouts must be deactivated for non-blocking actions
        if (true === $non_blocking) {
            $timeout = null;
        }

        // No deferred methods?  wait for new ones
        while (true) {
            try {
                list($frame_type, $payload) = $this->next_frame($timeout);
            } catch (AMQPNoDataException $e) {
                // no data ready for non-blocking actions - stop and exit
                break;
            } catch (AMQPConnectionClosedException $exception) {
                if ($this instanceof AMQPChannel) {
                    $this->do_close();
                }
                throw $exception;
            }

            $this->validate_method_frame($frame_type);
            $this->validate_frame_payload($payload);

            $method_sig = $this->build_method_signature($payload);
            $args = $this->extract_args($payload);

            $this->debug->debug_method_signature('> %s', $method_sig);

            $amqpMessage = $this->maybe_wait_for_content($method_sig);

            if ($this->should_dispatch_method($allowed_methods, $method_sig)) {
                return $this->dispatch($method_sig, $args, $amqpMessage);
            }

            // Wasn't what we were looking for? save it for later
            $this->debug->debug_method_signature('Queueing for later: %s', $method_sig);
            $this->method_queue[] = array($method_sig, $args, $amqpMessage);

            if ($non_blocking) {
                break;
            }
        }
    }
public function wait ( $ allowed_methods = null , $ non_blocking = false , $ timeout = 0 ) { $ this -> debug -> debug_allowed_methods ( $ allowed_methods ) ; $ deferred = $ this -> process_deferred_methods ( $ allowed_methods ) ; if ( $ deferred [ 'dispatch' ] === true ) { return $ this -> dispatch_deferred_method ( $ deferred [ 'queued_method' ] ) ; } // timeouts must be deactivated for non-blocking actions if ( true === $ non_blocking ) { $ timeout = null ; } // No deferred methods?  wait for new ones while ( true ) { try { list ( $ frame_type , $ payload ) = $ this -> next_frame ( $ timeout ) ; } catch ( AMQPNoDataException $ e ) { // no data ready for non-blocking actions - stop and exit break ; } catch ( AMQPConnectionClosedException $ exception ) { if ( $ this instanceof AMQPChannel ) { $ this -> do_close ( ) ; } throw $ exception ; } $ this -> validate_method_frame ( $ frame_type ) ; $ this -> validate_frame_payload ( $ payload ) ; $ method_sig = $ this -> build_method_signature ( $ payload ) ; $ args = $ this -> extract_args ( $ payload ) ; $ this -> debug -> debug_method_signature ( '> %s' , $ method_sig ) ; $ amqpMessage = $ this -> maybe_wait_for_content ( $ method_sig ) ; if ( $ this -> should_dispatch_method ( $ allowed_methods , $ method_sig ) ) { return $ this -> dispatch ( $ method_sig , $ args , $ amqpMessage ) ; } // Wasn't what we were looking for? save it for later $ this -> debug -> debug_method_signature ( 'Queueing for later: %s' , $ method_sig ) ; $ this -> method_queue [ ] = array ( $ method_sig , $ args , $ amqpMessage ) ; if ( $ non_blocking ) { break ; } } }
Wait for some expected AMQP methods and dispatch to them.
Unexpected methods are queued up for later calls to this PHP
method.

@param array $allowed_methods
@param bool $non_blocking
@param int|float|null $timeout
@throws \PhpAmqpLib\Exception\AMQPOutOfBoundsException
@throws \PhpAmqpLib\Exception\AMQPRuntimeException
@throws \PhpAmqpLib\Exception\AMQPTimeoutException
@throws \ErrorException
@return mixed
Wait for some expected AMQP methods and dispatch to them . Unexpected methods are queued up for later calls to this PHP method .