コード例 #1
0
ファイル: Mogile.php プロジェクト: shupp/File_Mogile
 /**
  * Constructor.
  *
  * @param array  $hosts   Array of trackers as 'hostname:port'
  * @param string $domain  The mogile domain.
  * @param array  $options Optional.  Array of option values.
  *
  * @throws File_Mogile_Exception
  */
 public function __construct(array $hosts, $domain = null, array $options = null)
 {
     if (is_array($options)) {
         foreach ($options as $name => $value) {
             switch ($name) {
                 case 'socketTimeout':
                     self::$socketTimeout = floatval($value);
                     break;
                 case 'streamTimeoutSeconds':
                     self::$streamTimeoutSeconds = (int) $value;
                     break;
                 case 'streamTimeoutMicroSeconds':
                     self::$streamTimeoutMicroSeconds = (int) $value;
                     break;
                 case 'commandTimeout':
                     self::$commandTimeout = intval($value);
                     break;
                 default:
                     throw new File_Mogile_Exception('Unrecognized option');
             }
         }
     }
     $this->_domain = $domain;
     shuffle($hosts);
     $this->hosts = $hosts;
     $this->connect();
 }