Enables/disables flow from peer

@param $active
@throws \PhpAmqpLib\Exception\AMQPTimeoutException if the specified operation timeout was exceeded
@return mixed
558517
public function flow($active)
    {
        list($class_id, $method_id, $args) = $this->protocolWriter->channelFlow($active);
        $this->send_method_frame(array($class_id, $method_id), $args);

        return $this->wait(array(
            $this->waitHelper->get_wait('channel.flow_ok')
        ), false, $this->channel_rpc_timeout);
    }
32237
public function performAccessTokenFlow($directResponse = true, Array $input = array())
  {
    $authServer = $this->getOAuth()->getAuthServer();

    try {

      // Get user input
      if (empty($input)) {
        $input = $this->getRequest()->all();
      }

      // Tell the auth server to issue an access token
      if ($directResponse) {
        return $this->resourceJson($authServer->issueAccessToken($input));
      }

      return $authServer->issueAccessToken($input);

    } catch (ClientException $e) {

      // Throw an exception because there was a problem with the client's request
      $response = array(
        'message'   => $authServer->getExceptionType($e->getCode()),
        'description' => $e->getMessage()
      );

      // make this better in order to return the correct headers via the response object
      $error   = $authServer->getExceptionType($e->getCode());
      $headers = $authServer->getExceptionHttpHeaders($error);

      if ($directResponse) {
        return $this->resourceJson($response, self::$exceptionHttpStatusCodes[$error], $headers);
      }

      $response['status']  = self::$exceptionHttpStatusCodes[$error];
      $response['headers'] = $headers;

      return $response;

    } catch (Exception $e) {

      // Throw an error when a non-library specific exception has been thrown
      $response = array(
        'message'   => 'undefined_error',
        'description' => $e->getMessage()
      );

      if ($directResponse) {
        return $this->resourceJson($response, 500);
      }

      $response['status'] = 500;

      return $response;
    }
  }
1323869
public function files($active = true)
    {
        $query = $this->morphToMany(File::class, 'uploadable')
        ->with('translations')
        ->withPivot('weight')
        ->orderBy('weight', 'ASC')
        ->withTimestamps();

        if ($active) {
            $query->where('is_active', '=', 1);
        }

        return $query;
    }
124084
private function executeHandles(&$active, &$mrc, $timeout = 1)
    {
        do {
            $mrc = curl_multi_exec($this->multiHandle, $active);
        } while ($mrc == CURLM_CALL_MULTI_PERFORM && $active);
        $this->checkCurlResult($mrc);

        // @codeCoverageIgnoreStart
        // Select the curl handles until there is any activity on any of the open file descriptors
        // See https://github.com/php/php-src/blob/master/ext/curl/multi.c#L170
        if ($active && $mrc == CURLM_OK && curl_multi_select($this->multiHandle, $timeout) == -1) {
            // Perform a usleep if a previously executed select returned -1
            // @see https://bugs.php.net/bug.php?id=61141
            usleep(100);
        }
        // @codeCoverageIgnoreEnd
    }
1029669
protected function streamSetTimeout()
    {
        $seconds = floor($this->timeout);
        $microseconds = round(($this->timeout - $seconds) * 1e6);

        return stream_set_timeout($this->resource, $seconds, $microseconds);
    }
480370
public function get_active()
    {
        if ($this->active !== null) {
            return $this->active;
        }

        if (!$this->sieve) {
            return $this->_set_error(self::ERROR_INTERNAL);
        }

        return $this->active = $this->sieve->getActive();
    }
985692
protected function switchActive($active, $save = true)
    {
        $this->forceFill(['activated_at' => boolval($active) ? now() : null]);

        return $save ? $this->save() : false;
    }
414440
public function setActive($active)
    {
        $this->active = $active;

        if($active && $this->activatedAt === null) {
            $this->activatedAt = new \DateTime();
        }

        if(!$active) {
            $this->activatedAt = null;
        }

        return $this;
    }
1327635
public function wait($timeout = 60)
    {
        $timeoutMicro = $timeout !== null ? microtime(true) + (float)$timeout : null;
        while ($this->isRunning()) {
            if ($timeout !== null && microtime(true) >= $timeoutMicro) {
                return null;
            }
            usleep(1000);
        }

        return $this->getExitCode();
    }
1296850
public function setIsActive($active)
    {
        $active = $active ? true : false;
        $this->isActive = $active;

        return $this;
    }
1105915
public function connect($timeout = 90) {
        $host = $this->getAuthenticator()->getHost();
        $port = $this->getAuthenticator()->getPort();
        $this->setConnection(@ftp_connect($host, $port, $timeout));
        if (false === $this->getConnection()) {
            throw $this->newFTPException("connection failed");
        }
        return $this;
    }
555744
public function handle(array $active)
    {
        foreach ($active as $resource) {
            $id = (int) $resource;
            if (isset($this->sockets[$id], $this->pending[$id])) { // Event may have been removed from a previous call.
                if (!$this->sockets[$id]->isPersistent()) {
                    unset($this->pending[$id]);
                    if (isset($this->timers[$id])) {
                        $this->timers[$id]->stop();
                    }
                } elseif (isset($this->timers[$id])) {
                    $this->timers[$id]->again();
                }

                $this->sockets[$id]->call(false);
            }
        }
    }
634475
public function isActive($active = null)
    {
        $res = $this->active;
        if ($active !== null) {
            if (!is_bool($active)) {
                throw new \Erebot\InvalidValueException(
                    'Invalid activation value'
                );
            }
            $this->active = $active;
        }
        return $res;
    }
629536
protected function _receive($timeout = null)
    {
        $this->checkConnection();

        if ($timeout !== null) {
            stream_set_timeout($this->_connection, $timeout);
        }

        $response = fgets($this->_connection, 1024);
        $info = stream_get_meta_data($this->_connection);

        if (!empty($info['timed_out'])) {
            throw new SMTPException(__('%s has timed out', array($this->_host)));
        } elseif ($response === false) {
            throw new SMTPException(__('Could not read from %s', array($this->_host)));
        }

        return $response;
    }
1226270
public function setConnectTimeout($timeout)
    {
        assert(is_int($timeout));
        assert($timeout >= 0);
        $this->_timeout = $timeout;

        return $this;
    }
896567
public function getAddons($active = false) {
        if ($active) {
            return array_keys($this->enabled);
        }
        return array_keys($this->addons);
    }
1142851
public function setStreamTimeout($seconds)
    {
        if ($this->isConnected() === true) {
            if (is_numeric($seconds) === true) {
                try {
                    $timeout      = number_format($seconds, 3);
                    $seconds      = floor($timeout);
                    $microseconds = (($timeout - $seconds) * 1000);
                    return stream_set_timeout($this->streamSocket, $seconds, $microseconds);
                } catch (\Exception $e) {
                    return false;
                }
            }
        }

        return false;
    }