示例#1
0
 /**
  * Creates a new CurlConsumer and assigns properties from the $options array
  * @param array $options
  * @throws Exception
  */
 function __construct($options)
 {
     parent::__construct($options);
     $this->_host = $options['host'];
     $this->_endpoint = $options['endpoint'];
     $this->_timeout = array_key_exists('timeout', $options) ? $options['timeout'] : 1;
     $this->_protocol = array_key_exists('use_ssl', $options) && $options['use_ssl'] == true ? "https" : "http";
     $this->_fork = array_key_exists('fork', $options) ? $options['fork'] == true : false;
     // ensure the environment is workable for the given settings
     if ($this->_fork == true) {
         $exists = function_exists('exec');
         if (!$exists) {
             throw new Exception('The "exec" function must exist to use the cURL consumer in "fork" mode. Try setting fork = false or use another consumer.');
         }
         $disabled = explode(', ', ini_get('disable_functions'));
         $enabled = !in_array('exec', $disabled);
         if (!$enabled) {
             throw new Exception('The "exec" function must be enabled to use the cURL consumer in "fork" mode. Try setting fork = false or use another consumer.');
         }
     } else {
         if (!function_exists('curl_init')) {
             throw new Exception('The cURL PHP extension is required to use the cURL consumer with fork = false. Try setting fork = true or use another consumer.');
         }
     }
 }
示例#2
0
 /**
  * Creates a new SocketConsumer and assigns properties from the $options array
  * @param array $options
  */
 public function __construct($options = array())
 {
     parent::__construct($options);
     $this->_host = $options['host'];
     $this->_endpoint = $options['endpoint'];
     $this->_connect_timeout = array_key_exists('connect_timeout', $options) ? $options['connect_timeout'] : 5;
     $this->_async = array_key_exists('async', $options) && $options['async'] === false ? false : true;
     if (array_key_exists('use_ssl', $options) && $options['use_ssl'] == true) {
         $this->_protocol = "ssl";
         $this->_port = 443;
     } else {
         $this->_protocol = "tcp";
         $this->_port = 80;
     }
 }
示例#3
0
 /**
  * Creates a new FileConsumer and assigns properties from the $options array
  * @param array $options
  */
 function __construct($options)
 {
     parent::__construct($options);
     // what file to write to?
     $this->_file = array_key_exists("file", $options) ? $options['file'] : dirname(__FILE__) . "/../../messages.txt";
 }