private function initOSDomain($hosts) { if ($hosts == null || count($hosts) == 0) { $hosts = isset(IGeTui::$appkeyUrlList[$this->appkey]) ? IGeTui::$appkeyUrlList[$this->appkey] : null; if ($hosts == null || count($hosts) == 0) { $hosts = $this->getOSPushDomainUrlList($this->domainUrlList, $this->appkey); IGeTui::$appkeyUrlList[$this->appkey] = $hosts; } } else { IGeTui::$appkeyUrlList[$this->appkey] = $hosts; } $this->host = ApiUrlRespectUtils::getFastest($this->appkey, $hosts); return $this->host; }
public static function getFastest($appkey, $hosts) { if ($hosts == null || count($hosts) == 0) { throw new Exception("Hosts cann't be null or size must greater than 0"); } if (isset(ApiUrlRespectUtils::$appkeyAndFasterHost[$appkey]) && count(array_diff($hosts, isset(ApiUrlRespectUtils::$appKeyAndHost[$appkey]) ? ApiUrlRespectUtils::$appKeyAndHost[$appkey] : null)) == 0) { return ApiUrlRespectUtils::$appkeyAndFasterHost[$appkey]; } else { $fastest = ApiUrlRespectUtils::getFastestRealTime($hosts); ApiUrlRespectUtils::$appKeyAndHost[$appkey] = $hosts; ApiUrlRespectUtils::$appkeyAndFasterHost[$appkey] = $fastest; return $fastest; } }
/** * @param $hosts * @return string * @throws \UnexpectedValueException * @throws \InvalidArgumentException */ private function initOSDomain($hosts) { if ($hosts === null || count($hosts) === 0) { if (array_key_exists($this->appkey, IGeTui::$appkeyUrlList)) { $hosts = IGeTui::$appkeyUrlList[$this->appkey]; } else { $hosts = $this->getOSPushDomainUrlList($this->domainUrlList, $this->appkey); IGeTui::$appkeyUrlList[$this->appkey] = $hosts; } } else { IGeTui::$appkeyUrlList[$this->appkey] = $hosts; } $this->host = ApiUrlRespectUtils::getFastest($this->appkey, $hosts); return $this->host; }