本文整理汇总了PHP中ZPush::GetPingTracking方法的典型用法代码示例。如果您正苦于以下问题:PHP ZPush::GetPingTracking方法的具体用法?PHP ZPush::GetPingTracking怎么用?PHP ZPush::GetPingTracking使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ZPush
的用法示例。
在下文中一共展示了ZPush::GetPingTracking方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: CheckForChanges
/**
* Checks if the currently known collections for changes for $lifetime seconds.
* If the backend provides a ChangesSink the sink will be used.
* If not every $interval seconds an exporter will be configured for each
* folder to perform GetChangeCount().
*
* @param int $lifetime (opt) total lifetime to wait for changes / default 600s
* @param int $interval (opt) time between blocking operations of sink or polling / default 30s
* @param boolean $onlyPingable (opt) only check for folders which have the PingableFlag
*
* @access public
* @return boolean indicating if changes were found
* @throws StatusException with code SyncCollections::ERROR_NO_COLLECTIONS if no collections available
* with code SyncCollections::ERROR_WRONG_HIERARCHY if there were errors getting changes
*/
public function CheckForChanges($lifetime = 600, $interval = 30, $onlyPingable = false)
{
$classes = array();
foreach ($this->collections as $folderid => $spa) {
if ($onlyPingable && $spa->GetPingableFlag() !== true) {
continue;
}
if (!isset($classes[$spa->GetContentClass()])) {
$classes[$spa->GetContentClass()] = 0;
}
$classes[$spa->GetContentClass()] += 1;
}
if (empty($classes)) {
$checkClasses = "policies only";
} else {
if (array_sum($classes) > 4) {
$checkClasses = "";
foreach ($classes as $class => $count) {
if ($count == 1) {
$checkClasses .= sprintf("%s ", $class);
} else {
$checkClasses .= sprintf("%s(%d) ", $class, $count);
}
}
} else {
$checkClasses = implode(" ", array_keys($classes));
}
}
$pingTracking = ZPush::GetPingTracking();
$this->changes = array();
$changesAvailable = false;
ZPush::GetDeviceManager()->AnnounceProcessAsPush();
ZPush::GetTopCollector()->AnnounceInformation(sprintf("lifetime %ds", $lifetime), true);
ZLog::Write(LOGLEVEL_INFO, sprintf("SyncCollections->CheckForChanges(): Waiting for %s changes... (lifetime %d seconds)", empty($classes) ? 'policy' : 'store', $lifetime));
// use changes sink where available
$changesSink = false;
$forceRealExport = 0;
// do not create changessink if there are no folders
if (!empty($classes) && ZPush::GetBackend()->HasChangesSink()) {
$changesSink = true;
// initialize all possible folders
foreach ($this->collections as $folderid => $spa) {
if ($onlyPingable && $spa->GetPingableFlag() !== true) {
continue;
}
// switch user store if this is a additional folder and initialize sink
ZPush::GetBackend()->Setup(ZPush::GetAdditionalSyncFolderStore($folderid));
if (!ZPush::GetBackend()->ChangesSinkInitialize($folderid)) {
throw new StatusException(sprintf("Error initializing ChangesSink for folder id '%s'", $folderid), self::ERROR_WRONG_HIERARCHY);
}
}
}
// wait for changes
$started = time();
$endat = time() + $lifetime;
// always use policy key from the request if it was sent
$policyKey = $this->GetReferencePolicyKey();
if (Request::WasPolicyKeySent() && Request::GetPolicyKey() != 0) {
ZLog::Write(LOGLEVEL_DEBUG, sprintf("refpolkey:'%s', sent polkey:'%s'", $policyKey, Request::GetPolicyKey()));
$policyKey = Request::GetPolicyKey();
}
while (($now = time()) < $endat) {
// how long are we waiting for changes
$this->waitingTime = $now - $started;
$nextInterval = $interval;
// we should not block longer than the lifetime
if ($endat - $now < $nextInterval) {
$nextInterval = $endat - $now;
}
// Check if provisioning is necessary
// if a PolicyKey was sent use it. If not, compare with the ReferencePolicyKey
if (PROVISIONING === true && $policyKey !== false && ZPush::GetDeviceManager()->ProvisioningRequired($policyKey, true)) {
// the hierarchysync forces provisioning
throw new StatusException("SyncCollections->CheckForChanges(): PolicyKey changed. Provisioning required.", self::ERROR_WRONG_HIERARCHY);
}
// Check if a hierarchy sync is necessary
if (ZPush::GetDeviceManager()->IsHierarchySyncRequired()) {
throw new StatusException("SyncCollections->CheckForChanges(): HierarchySync required.", self::HIERARCHY_CHANGED);
}
// Check if there are newer requests
// If so, this process should be terminated if more than 60 secs to go
if ($pingTracking->DoForcePingTimeout()) {
// do not update CPOs because another process has already read them!
$this->saveData = false;
// more than 60 secs to go?
//.........这里部分代码省略.........